コード例 #1
0
ファイル: CronService.php プロジェクト: t4web/cron
 protected function assembleErrorString()
 {
     $string = 'Jobs: ' . PHP_EOL;
     $i = 1;
     foreach ($this->cron->getExecutor()->getRunningJobs() as $job) {
         $string .= $i . '. ' . $job->getProcess()->getCommandLine() . PHP_EOL;
         $i++;
     }
     return $string . ' have taken over ' . $this->timeout . ' seconds to execute.';
 }
コード例 #2
0
ファイル: CronServiceFactory.php プロジェクト: t4web/cron
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return CronService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get(Config::class);
     $resolver = new ArrayResolver($config->getPhpPath(), $config->getScriptPath());
     $resolver->buildFromConfig($config->getJobs());
     $cron = new Cron();
     $cron->setResolver($resolver);
     $cron->setExecutor(new Executor());
     return new CronService($config->getTimeout(), $cron);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $cron = new Cron();
     $cron->setExecutor($this->getContainer()->get('cron.executor'));
     if ($input->getArgument('job')) {
         $resolver = $this->getJobResolver($input->getArgument('job'), $input->hasOption('force'));
     } else {
         $resolver = $this->getContainer()->get('cron.resolver');
     }
     $cron->setResolver($resolver);
     $time = microtime(true);
     $dbReport = $cron->run();
     while ($cron->isRunning()) {
     }
     $output->writeln('time: ' . (microtime(true) - $time));
     $manager = $this->getContainer()->get('cron.manager');
     $manager->saveReports($dbReport->getReports());
 }
コード例 #4
0
 protected function wait()
 {
     do {
         sleep(1);
     } while ($this->cron->isRunning() && !$this->checkTimeout());
 }