/** * 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; }
public function testShouldFailIfMaxRuntimeExceeded() { $jobby = new Jobby(); $jobby->add('slow job', ['command' => 'sleep 4', 'schedule' => '* * * * *', 'maxRuntime' => 1, 'output' => $this->logFile]); $jobby->run(); sleep(2); $jobby->run(); sleep(1); $this->assertContains('ERROR: MaxRuntime of 1 secs exceeded!', $this->getLogContent()); }
public function testShouldFailIfMaxRuntimeExceeded() { if ($this->helper->getPlatform() === Helper::WINDOWS) { $this->markTestSkipped("'maxRuntime' is not supported on Windows"); } $jobby = new Jobby(); $jobby->add('slow job', ['command' => 'sleep 4', 'schedule' => '* * * * *', 'maxRuntime' => 1, 'output' => $this->logFile]); $jobby->run(); sleep(2); $jobby->run(); sleep(2); $this->assertContains('ERROR: MaxRuntime of 1 secs exceeded!', $this->getLogContent()); }