mirror of
https://github.com/Icinga/docker-icingaweb2.git
synced 2025-10-23 21:11:00 +02:00
Merge pull request #89 from Icinga/db-conn-refused
Entrypoint: re-try database connection on error for <=5m
This commit is contained in:
commit
ce71661ede
@ -11,6 +11,7 @@ use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Module\Setup\Utils\DbTool;
|
||||
use Icinga\Util\Json;
|
||||
use PDOException;
|
||||
|
||||
class DbCommand extends Command
|
||||
{
|
||||
@ -94,6 +95,20 @@ class DbCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
try {
|
||||
(new DbTool($config))->checkConnectivity();
|
||||
break;
|
||||
} catch (PDOException $e) {
|
||||
fprintf(
|
||||
STDERR, "[%s] [docker_entrypoint:error] [pid %d] DOCKERE: Can't connect to database: %s\n",
|
||||
date('D M j H:i:s.u Y'), getmypid(), $e->getMessage()
|
||||
);
|
||||
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
|
||||
$db = new DbTool($config);
|
||||
$db->connectToDb();
|
||||
$db->dbType = $type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user