DeploymentChecker: new Background Daemon component
fixes #2045 fixes #1988
This commit is contained in:
parent
0788742387
commit
4d406621aa
|
@ -52,8 +52,7 @@ class ConfigController extends ActionController
|
|||
$this->addTitle($this->translate('Deployments'));
|
||||
try {
|
||||
if (DirectorDeploymentLog::hasUncollected($this->db())) {
|
||||
$this->setAutorefreshInterval(3);
|
||||
$this->api()->collectLogFiles($this->db());
|
||||
$this->setAutorefreshInterval(2);
|
||||
} else {
|
||||
$this->setAutorefreshInterval(20);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ next (will be 1.8.0)
|
|||
* FIX: Daemon Logger used to not override the given log level (#2139)
|
||||
* FEATURE: Daemon: prepare for future reactphp promise versions (#2137)
|
||||
* FEATURE: Daemon now logs that it is going to reload itself
|
||||
* FEATURE: Now collects the Deployment status from Icinga (#2045, #1988)
|
||||
|
||||
### Documentation
|
||||
* FEATURE: We now also mention optional/indirect requirements (#2054, #2220)
|
||||
|
|
|
@ -87,6 +87,7 @@ class BackgroundDaemon
|
|||
$this->daemonDb
|
||||
->register($this->jobRunner)
|
||||
->register($this->logProxy)
|
||||
->register(new DeploymentChecker($this->loop))
|
||||
->run($this->loop);
|
||||
$this->setState('running');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue