Add retries when job execute failed
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user