Fix init startup
This commit is contained in:
parent
48f143547a
commit
5dd31bcdfb
1 changed files with 18 additions and 14 deletions
32
app/cli.php
32
app/cli.php
|
@ -179,25 +179,29 @@ $cli
|
|||
do {
|
||||
$attempts++;
|
||||
|
||||
// Prepare database connection
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
->getResource();
|
||||
try {
|
||||
// Prepare database connection
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
->getResource();
|
||||
|
||||
$dbForConsole = new Database($dbAdapter, $cache);
|
||||
$dbForConsole->setNamespace('console');
|
||||
$dbForConsole = new Database($dbAdapter, $cache);
|
||||
$dbForConsole->setNamespace('console');
|
||||
|
||||
// Ensure tables exist
|
||||
$collections = Config::getParam('collections', []);
|
||||
$last = \array_key_last($collections);
|
||||
// Ensure tables exist
|
||||
$collections = Config::getParam('collections', []);
|
||||
$last = \array_key_last($collections);
|
||||
|
||||
if (!($dbForConsole->exists($dbForConsole->getDefaultDatabase(), $last))) {
|
||||
throw new Exception('Tables not ready yet.');
|
||||
}
|
||||
|
||||
if ($dbForConsole->exists($dbForConsole->getDefaultDatabase(), $last)) {
|
||||
$ready = true;
|
||||
break;
|
||||
} catch (\Exception $err) {
|
||||
Console::warning($err->getMessage());
|
||||
sleep($sleep);
|
||||
}
|
||||
|
||||
sleep($sleep);
|
||||
} while ($attempts < $maxAttempts);
|
||||
|
||||
if (!$ready) {
|
||||
|
|
Loading…
Reference in a new issue