run() public method

Run all jobs.
public run ( )
Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 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());
 }
Esempio n. 3
0
 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());
 }