public function run()
{
$isUnix = $this->helper->getPlatform() === Helper::UNIX;
if ($isUnix && !extension_loaded('posix')) {
throw new Exception('posix extension is required');
}
$scheduleChecker = new ScheduleChecker();
foreach ($this->jobs as $job => $config) {
if (!$scheduleChecker->isDue($config['schedule'])) {
continue;
}
if ($isUnix) {
$this->runUnix($job, $config);
} else {
$this->runWindows($job, $config);
}
}
}
/** * Jobby scheduler entry point */ public function actionRun() { $jobby = new Jobby(); $tasks = $this->getTasks(); /** @var JobbyModelInterface[] $tasks */ foreach ($tasks as $task) { $output = $task->getJobbyOutput(); $jobby->add($task->getPrimaryKey(), ['command' => $task->getJobbyCommand(), 'schedule' => $task->getJobbySchedule(), 'output' => $output ? $output : null, 'enabled' => $task->getJobbyEnabled(), 'debug' => false]); } $jobby->run(); echo count($tasks) . ' jobby tasks found' . PHP_EOL; }