Run one job at a time.
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user