blob: 82d6d0580a58bcbd665178a7b55205272a51c6ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?php
namespace Icinga\Module\Director\Daemon;
use Exception;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
use React\EventLoop\LoopInterface;
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 \React\Promise\ExtendedPromiseInterface
*/
public function initDb(Db $connection)
{
$this->connection = $connection;
return resolve();
}
/**
* @return \React\Promise\ExtendedPromiseInterface
*/
public function stopDb()
{
$this->connection = null;
return resolve();
}
}
|