mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 10:57:41 +02:00
DirectorJob: really run jobs
This commit is contained in:
parent
2d8d7af051
commit
53872a4e76
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects;
|
|||||||
|
|
||||||
use Icinga\Module\Director\Data\Db\DbObjectWithSettings;
|
use Icinga\Module\Director\Data\Db\DbObjectWithSettings;
|
||||||
use Icinga\Module\Director\Hook\JobHook;
|
use Icinga\Module\Director\Hook\JobHook;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class DirectorJob extends DbObjectWithSettings
|
class DirectorJob extends DbObjectWithSettings
|
||||||
{
|
{
|
||||||
@ -45,7 +46,31 @@ class DirectorJob extends DbObjectWithSettings
|
|||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$this->job()->setDefinition($this)->run();
|
$job = $this->job()->setDefinition($this);
|
||||||
|
$this->ts_last_attempt = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$job->run();
|
||||||
|
$this->last_attempt_succeeded = 'y';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->ts_last_error = date('Y-m-d H:i:s');
|
||||||
|
$this->last_error_message = $e->getMessage();
|
||||||
|
$this->last_attempt_succeeded = 'n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->hasBeenModified()) {
|
||||||
|
$this->store();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldRun()
|
||||||
|
{
|
||||||
|
return (! $this->hasBeenDisabled()) && $this->isPending();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasBeenDisabled()
|
||||||
|
{
|
||||||
|
return $this->disabled === 'y';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPending()
|
public function isPending()
|
||||||
@ -54,7 +79,7 @@ class DirectorJob extends DbObjectWithSettings
|
|||||||
return $this->isWithinTimeperiod();
|
return $this->isWithinTimeperiod();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strtotime($this->unixts_last_attempt) + $this->run_interval < time()) {
|
if (strtotime($this->ts_last_attempt) + $this->run_interval < time()) {
|
||||||
return $this->isWithinTimeperiod();
|
return $this->isWithinTimeperiod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user