Skip to content

Commit

Permalink
Sometimes db process is up but o accepting queries so use a better wa…
Browse files Browse the repository at this point in the history
…y to detect readiness
  • Loading branch information
rsanzante committed Sep 11, 2023
1 parent 8197e02 commit 9c5b3e0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Composer/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,11 @@ protected function waitDatabase() {
$count = 10;
while ($count) {
$this->io->write('Waiting for database to be ready....');
$result = exec('docker-compose ps --services --filter "status=running" | grep mariadb| wc -l');

$result = exec('. ./.env; docker-compose exec -u root mariadb mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME} -e "SELECT 1 AS result"| grep "1 |" | wc -l');
if ($result === "1") {
$this->io->write('Database ready!');
return;
}

sleep(1);
$count--;
}
Expand Down

0 comments on commit 9c5b3e0

Please sign in to comment.