setClient($client); } public function setClient(ClientInterface $client) { $this->client = $client; return $this; } public function getClient(): ClientInterface { return $this->client; } public function execute(InputInterface $input, OutputInterface $output) { $response = $this->getClient()->get('/queues/pending'); if ($response->getStatusCode() !== 200) { return Command::FAILURE; } $data = json_decode($response->getBody()->getContents()); $output = [ 'input' => $data, 'processed' => [] ]; foreach ($data->pending as $queue) { $log = "Running {$queue->command} from queue. Created in {$queue->created}."; error_log($log); $cmd = '/usr/local/bin/php /app/bin/console ' . $queue->cmd; exec($cmd, $result, $code); if ($code != Command::SUCCESS) { error_log(var_export($queue, true)); error_log(var_export($result, true)); continue; } $output['processed'] []= $queue->id; } $response = $this->getClient()->post('/queues/processed', ['json' => $output]); if ($response->getStatusCode() !== 200) { return Command::FAILURE; } return Command::SUCCESS; } }