/**
* @return bool
*/
protected function shouldRun()
{
if (!$this->config['enabled']) {
return false;
}
if ($this->config['haltDir'] !== null) {
$flag_file = $this->config['haltDir'] . DIRECTORY_SEPARATOR . $this->job;
if (file_exists($flag_file)) {
return false;
}
}
$schedule = \DateTime::createFromFormat('Y-m-d H:i:s', $this->config['schedule']);
if ($schedule !== false) {
return $schedule->format('Y-m-d H:i') == date('Y-m-d H:i');
}
$cron = CronExpression::factory($this->config['schedule']);
if (!$cron->isDue()) {
return false;
}
$host = $this->helper->getHost();
if (strcasecmp($this->config['runOnHost'], $host) != 0) {
return false;
}
return true;
}