Ejemplo n.º 1
0
 /**
  * @param RouteCollection $collection
  * @param Jobby $jobby
  * @param array $cron
  * @throws \JetFire\Jobby\Exception
  */
 public function init(RouteCollection $collection, Jobby $jobby, $cron = [])
 {
     $this->jobby = $jobby;
     foreach ($cron as $name => $job) {
         if (isset($job['controller'])) {
             $job['closure'] = $this->getClosure($job, $collection);
         } elseif (isset($job['file'])) {
             $job['closure'] = function () use($job) {
                 require $job['file'];
             };
         }
         if (!isset($job['output'])) {
             $job['output'] = ROOT . '/storage/cron/command.log';
         }
         $this->jobby->add($name, $job);
     }
 }
Ejemplo 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(2);
     $this->assertContains('ERROR: MaxRuntime of 1 secs exceeded!', $this->getLogContent());
 }