protected function execute(InputInterface $input, OutputInterface $output) { $jobId = $input->getArgument('jobId'); $this->elasticsearch = $this->getContainer()->get('syrup.elasticsearch.search'); /** @var Job $job */ $job = $this->elasticsearch->getJob($jobId); if ($job->getStatus() != Job::STATUS_PROCESSING && $job->getStatus() != Job::STATUS_WAITING) { $output->writeln("<error>Job {$jobId} is not in 'waiting' or 'processing' state</error>"); } else { // update job status and possibly kill it if ($job->getStatus() == Job::STATUS_WAITING) { $job->setStatus(Job::STATUS_CANCELLED); $job->setResult(['message' => 'Job cancelled by user']); $output->writeln("<info>Job {$jobId} cancelled</info>"); $this->elasticsearch->updateJob($job); } else { $job->setStatus(Job::STATUS_TERMINATING); $this->elasticsearch->updateJob($job); // @TODO: send message to SNS } } }