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.'; }
/** * 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); }
/** * {@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()); }
protected function wait() { do { sleep(1); } while ($this->cron->isRunning() && !$this->checkTimeout()); }