Skip to content

Commit

Permalink
smarter waiting for the database
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 23, 2024
1 parent 0f72e64 commit f5718c8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scripts/local-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,15 @@ function start_webserver() {
fi
}

function wait_for_database() {
echo "waiting for database..."
while ! php -r "\$pdo = new PDO('mysql:host=$WP_DB_HOST', 'root', 'pass');\$pdo->exec('SELECT VERSION()');" > /dev/null
do
sleep 2
done
echo "database running."
}

echo "local-dev-entrypoint" "$@"

export_global
Expand All @@ -542,9 +551,7 @@ if [[ "$EXECUTE_CLI" = "1" ]]; then
handle_cli_command "$@"
fi

echo "waiting for database..."
sleep 5 # wait for database
echo "done."
wait_for_database

# install normal wordpress + multisite wordpress
install_wordpress 0
Expand Down

0 comments on commit f5718c8

Please sign in to comment.