12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
56 parent::__construct();
66 $this->setName(
'setup:cron:run')
67 ->setDescription(
'Runs cron job scheduled for setup application');
77 $notification =
'setup-cron: Please check var/log/update.log for execution summary.';
79 if (!$this->deploymentConfig->isAvailable()) {
80 $output->writeln($notification);
82 return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
85 if (!$this->checkRun()) {
86 $output->writeln($notification);
88 return \Magento\Framework\Console\Cli::RETURN_FAILURE;
91 $this->status->toggleUpdateInProgress();
94 $output->writeln($notification);
96 return \Magento\Framework\Console\Cli::RETURN_FAILURE;
99 $returnCode = $this->executeJobsFromQueue();
101 $output->writeln($notification);
112 private function checkRun()
114 return $this->readinessCheck->runReadinessCheck()
115 && !$this->status->isUpdateInProgress()
116 && !$this->status->isUpdateError();
124 private function executeJobsFromQueue()
128 while (!empty($this->queue->peek()) && strpos($this->queue->peek()[
Queue::KEY_JOB_NAME],
'setup:') === 0) {
129 $job = $this->queue->popQueuedJob();
131 sprintf(
'Job "%s" has started' . PHP_EOL, $job),
137 sprintf(
'Job "%s" has been successfully completed', $job),
141 $this->status->toggleUpdateError(
true);
143 sprintf(
'An error occurred while executing job "%s": %s', $job, $e->getMessage()),
149 }
catch (\Exception $e) {
151 $this->status->toggleUpdateError(
true);
154 $this->status->toggleUpdateInProgress(
false);
execute(InputInterface $input, OutputInterface $output)
__construct(DeploymentConfig $deploymentConfig, Queue $queue, ReadinessCheck $readinessCheck, Status $status)