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 {
|
do {
|
||||||
$attempts++;
|
$attempts++;
|
||||||
|
|
||||||
// Prepare database connection
|
try {
|
||||||
$dbAdapter = $pools
|
// Prepare database connection
|
||||||
->get('console')
|
$dbAdapter = $pools
|
||||||
->pop()
|
->get('console')
|
||||||
->getResource();
|
->pop()
|
||||||
|
->getResource();
|
||||||
|
|
||||||
$dbForConsole = new Database($dbAdapter, $cache);
|
$dbForConsole = new Database($dbAdapter, $cache);
|
||||||
$dbForConsole->setNamespace('console');
|
$dbForConsole->setNamespace('console');
|
||||||
|
|
||||||
// Ensure tables exist
|
// Ensure tables exist
|
||||||
$collections = Config::getParam('collections', []);
|
$collections = Config::getParam('collections', []);
|
||||||
$last = \array_key_last($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;
|
$ready = true;
|
||||||
break;
|
} catch (\Exception $err) {
|
||||||
|
Console::warning($err->getMessage());
|
||||||
|
sleep($sleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($sleep);
|
|
||||||
} while ($attempts < $maxAttempts);
|
} while ($attempts < $maxAttempts);
|
||||||
|
|
||||||
if (!$ready) {
|
if (!$ready) {
|
||||||
|
|
Loading…
Reference in a new issue