mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
Both now require an explicit value argument. Ref: https://github.com/reactphp/promise/releases/tag/v3.0.0
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Icinga\Module\Director\Daemon;
|
|
|
|
use Exception;
|
|
use Icinga\Module\Director\Db;
|
|
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
|
use React\EventLoop\LoopInterface;
|
|
use React\Promise\PromiseInterface;
|
|
|
|
use function React\Promise\resolve;
|
|
|
|
class DeploymentChecker implements DbBasedComponent
|
|
{
|
|
/** @var Db */
|
|
protected $connection;
|
|
|
|
public function __construct(LoopInterface $loop)
|
|
{
|
|
$loop->addPeriodicTimer(5, function () {
|
|
if ($db = $this->connection) {
|
|
try {
|
|
if (DirectorDeploymentLog::hasUncollected($db)) {
|
|
$db->getDeploymentEndpoint()->api()->collectLogFiles($db);
|
|
}
|
|
} catch (Exception $e) {
|
|
// Ignore eventual issues while talking to Icinga
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param Db $connection
|
|
*
|
|
* @return PromiseInterface
|
|
*/
|
|
public function initDb(Db $connection)
|
|
{
|
|
$this->connection = $connection;
|
|
|
|
return resolve(null);
|
|
}
|
|
|
|
/**
|
|
* @return PromiseInterface
|
|
*/
|
|
public function stopDb()
|
|
{
|
|
$this->connection = null;
|
|
|
|
return resolve(null);
|
|
}
|
|
}
|