Add retries when job execute failed

This commit is contained in:
Juan Pablo Vial
2025-07-15 23:07:32 -04:00
parent c512d7a79a
commit d3d6940842

View File

@ -59,6 +59,8 @@ class Queue extends Ideal\Service
try {
if (!$worker->execute($job)) {
$this->logger->debug("Could not execute job {$job->id}");
$job->retries++;
$this->jobService->update($job);
return false;
}
if (!$this->jobService->execute($job)) {
@ -67,6 +69,12 @@ class Queue extends Ideal\Service
}
} catch (Exception $exception) {
$this->logger->warning("Could not run job {$job->id}", ['exception' => $exception]);
$job->retries++;
try {
$this->jobService->update($job);
} catch (Update $exception) {
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]);
}
return false;
}
return true;