コード例 #1
0
 /**
  * Runs a scheduled job.
  *
  * @param CronJob         $job
  * @param array           $jobInfo
  * @param OutputInterface $output
  *
  * @return Run $run
  */
 private function runJob(CronJob $job, array $jobInfo, OutputInterface $output)
 {
     $output->writeln("-- Starting {$job->id}...");
     // set up the runner
     $class = array_value($jobInfo, 'class');
     $runner = new Runner($job, $class);
     // set up an object to track this run
     $run = new Run();
     $run->setConsoleOutput($output);
     // and go!
     $runner->go($jobInfo['expires'], $jobInfo['successUrl'], $run);
     if ($run->succeeded()) {
         $output->writeln('-- Success!');
     } elseif ($run->getResult() == Run::RESULT_LOCKED) {
         $output->writeln("{$job->id} is locked!");
     } elseif ($run->failed()) {
         $output->writeln('-- Failed!');
     }
     return $run;
 }
コード例 #2
0
 /**
  * Pings a URL about a successful run.
  *
  * @param string $url
  * @param Run    $run
  */
 private function pingSuccessUrl($url, Run $run)
 {
     if (!$url) {
         return;
     }
     $url .= '?m=' . urlencode($run->getOutput());
     @file_get_contents($url);
 }