diff --git a/cli/crontab b/cli/crontab index a0f9640..5c0c588 100644 --- a/cli/crontab +++ b/cli/crontab @@ -7,5 +7,5 @@ 0 2 * * * /code/bin/incoviba money:uf >> /logs/commands 2>&1 0 2 * * * /code/bin/incoviba money:uf:update >> /logs/commands 2>&1 0 2 1 * * /code/bin/incoviba money:ipc >> /logs/commands 2>&1 -*/2 * * * * /code/bin/incoviba queue >> /logs/commands 2>&1 +*/1 * * * * /code/bin/incoviba queue >> /logs/commands 2>&1 0 3 * * * /code/bin/incoviba external:services >> /logs/commands 2>&1 diff --git a/cli/src/Command/Queue.php b/cli/src/Command/Queue.php index 5efd4ed..faf19cd 100644 --- a/cli/src/Command/Queue.php +++ b/cli/src/Command/Queue.php @@ -44,10 +44,11 @@ class Queue extends Command } $io->writeln("Found {$jobCount} jobs to run"); - $result = $this->runJobs($io, $jobs); + $result = $this->runJob($jobs[0]); + /*$result = $this->runJobs($io, $jobs); foreach ($this->outputs as $output) { $this->sections['bottom']->writeln($output); - } + }*/ return $result; } @@ -109,4 +110,28 @@ class Queue extends Command } return self::SUCCESS; } + protected function runJob(int $jobId): int + { + $baseCommand = "{$this->baseCommand} jobs:run"; + $command = "{$baseCommand} {$jobId}"; + try { + exec($command, $output, $resultCode); + $this->outputs []= $output; + } catch (Throwable $exception) { + $this->logger->error("Failed to run command", [ + 'command' => $command, + 'exception' => $exception + ]); + return self::FAILURE; + } + if ($resultCode !== 0) { + $this->logger->error("Failed to run command", [ + 'command' => $command, + 'result_code' => $resultCode + ]); + return self::FAILURE; + } else { + return self::SUCCESS; + } + } }