diff --git a/app/src/Service/Job.php b/app/src/Service/Job.php index a02db33..f0b2524 100644 --- a/app/src/Service/Job.php +++ b/app/src/Service/Job.php @@ -6,6 +6,7 @@ use DateTimeZone; use InvalidArgumentException; use OutOfRangeException; use Psr\Log\LoggerInterface; +use Predis\Connection\ConnectionException; use Incoviba\Common\Ideal; use Incoviba\Common\Implement\Exception\EmptyRedis; use Incoviba\Common\Implement\Exception\EmptyResult; @@ -36,7 +37,7 @@ class Job extends Ideal\Service }); } return array_map([$this, 'load'], $jobs); - } catch (EmptyRedis) { + } catch (ConnectionException | EmptyRedis) { return []; } } diff --git a/app/src/Service/Queue.php b/app/src/Service/Queue.php index 09b6a76..100f00d 100644 --- a/app/src/Service/Queue.php +++ b/app/src/Service/Queue.php @@ -28,7 +28,7 @@ class Queue extends Ideal\Service try { $this->jobService->add($configuration); return true; - } catch (Create $exception) { + } catch (Read $exception) { $final = new Exception("Could not enqueue job", 0, $exception); $this->logger->warning($final); return false; @@ -82,12 +82,10 @@ class Queue extends Ideal\Service } public function run(?RequestInterface $request = null): bool { - try { - $jobs = $this->jobService->getPending(); - } catch (Read $exception) { - $final = new Exception("Could not get pending jobs", 0, $exception); - $this->logger->warning($final); - return false; + $jobs = $this->jobService->getPending(); + if (count($jobs) === 0) { + $this->logger->debug("No pending jobs"); + return true; } $errors = [];