コード例 #1
0
 /**
  * @param string $jobIdentifier
  * @param array $options
  */
 public function executeAction($jobIdentifier, array $options = [])
 {
     ini_set('memory_limit', -1);
     $jobConfiguration = $this->jobConfigurationRepository->findOneByIdentifier($jobIdentifier);
     try {
         if ($jobConfiguration === null) {
             $this->addFlashMessage(sprintf('Unable to find a Job Configuration with identifier "%s"', $jobIdentifier), '', Message::SEVERITY_ERROR);
             $this->redirect('index');
         }
         if (isset($this->settings['maximumExecutionTime'])) {
             set_time_limit((int) $this->settings['maximumExecutionTime']);
         }
         $startTime = microtime(true);
         $options = new JobConfigurationOptions($options);
         if ($this->jobRunnerService->execute($jobConfiguration, $options)) {
             if ($jobConfiguration->isAsynchronous()) {
                 $this->addFlashMessage(sprintf('Job "%s" queued with success', $jobConfiguration->getName()), '', Message::SEVERITY_OK);
             } else {
                 $duration = round(microtime(true) - $startTime, 2);
                 if ($duration > 0) {
                     $message = sprintf('Job "%s" exectued with success in %s sec.', $jobConfiguration->getName(), $duration);
                 } else {
                     $message = sprintf('Job "%s" exectued with success.', $jobConfiguration->getName());
                 }
                 $this->addFlashMessage($message, '', Message::SEVERITY_OK);
             }
         }
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
         $this->addFlashMessage(sprintf('Failed to execute job "%s" with message: %s', $jobConfiguration->getName(), $exception->getMessage()), '', Message::SEVERITY_ERROR);
     }
     $this->redirect('index');
 }
コード例 #2
0
 /**
  * @param string $jobIdentifier
  * @param array $options
  */
 protected function executeJob($jobIdentifier, array $options = [])
 {
     $jobConfiguration = $this->jobConfigurationRepository->findOneByIdentifier($jobIdentifier);
     try {
         $startTime = microtime(true);
         $options = new JobConfigurationOptions($options);
         if ($this->jobRunnerService->execute($jobConfiguration, $options)) {
             if ($jobConfiguration->isAsynchronous()) {
                 $this->flashMessageContainer->addMessage(new Message(sprintf('Job "%s" queued with success', $jobConfiguration->getName())));
             } else {
                 $duration = round(microtime(true) - $startTime, 2);
                 $this->flashMessageContainer->addMessage(new Message(sprintf('Job "%s" exectued with success in %s sec.', $jobConfiguration->getName(), $duration)));
             }
         }
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
         $this->flashMessageContainer->addMessage(new Error(sprintf('Failed to execute job "%s" with message: %s', $jobConfiguration->getName(), $exception->getMessage())));
     }
 }