Beispiel #1
0
 /**
  * Create restored job report.
  *
  * @param JobConfigurationInterface $configuration
  *
  * @return JobReportInterface
  */
 private function createReport(JobConfigurationInterface $configuration)
 {
     $report = $this->reportManager->create($configuration);
     $report->setEndedAt(new \DateTime());
     $report->setOutput('Job was dead and restored.');
     $report->setSuccessful(true);
     $this->reportManager->add($report);
     return $report;
 }
Beispiel #2
0
 /**
  * Run job queue.
  *
  * @param string $queue
  */
 public function run($queue)
 {
     $configuration = $this->getConfiguration($queue);
     if (null === $configuration) {
         return;
     }
     try {
         $job = $this->jobProvider->getFactory($configuration)->create($configuration);
         $configuration->setOrderNr($configuration->getOrderNr() + 1);
         $this->saveJobState($configuration, JobState::STATE_RUNNING);
         $report = $this->reportManager->create($configuration);
         $state = $job->run($report);
         if ($state === JobState::STATE_FINISHED) {
             $configuration->setNextStart(new \DateTime('+' . $configuration->getPeriod() . ' seconds'));
             $report->setSuccessful(true);
         }
         $configuration->addReport($report);
         $report->setEndedAt(new \DateTime());
         $this->saveJobState($configuration, $state);
     } catch (JobFactoryException $e) {
         $this->saveJobState($configuration, JobState::STATE_FAILED);
     }
 }
 /**
  * @param JobConfigurationInterface $configuration
  * @param Request $request
  *
  * @return Pagination
  */
 private function createPagination(JobConfigurationInterface $configuration, Request $request)
 {
     $count = $this->reportManager->getCountByConfiguration($configuration);
     return new Pagination($request->get('page', 1), 50, $count);
 }