From 67655e9b5c3a7aa6be3e3486eabe3f1814159912 Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Thu, 18 Aug 2022 16:45:23 +0200
Subject: [PATCH] do not stop request fetcher before all jobs completed

---
 metager/app/Console/Commands/RequestFetcher.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/metager/app/Console/Commands/RequestFetcher.php b/metager/app/Console/Commands/RequestFetcher.php
index 6b12321ed..40c9eb310 100644
--- a/metager/app/Console/Commands/RequestFetcher.php
+++ b/metager/app/Console/Commands/RequestFetcher.php
@@ -72,7 +72,7 @@ class RequestFetcher extends Command
         }
 
         try {
-            while ($this->shouldRun) {
+            while (true) {
                 Redis::set(self::HEALTHCHECK_KEY, Carbon::now()->format(self::HEALTHCHECK_FORMAT));
                 $operationsRunning = true;
                 curl_multi_exec($this->multicurl, $operationsRunning);
@@ -84,6 +84,9 @@ class RequestFetcher extends Command
                 if ($newJobs === 0 && $answersRead === 0) {
                     usleep(10 * 1000);
                 }
+                if (!$this->shouldRun && $operationsRunning === 0) {
+                    break;
+                }
             }
         } finally {
             curl_multi_close($this->multicurl);
-- 
GitLab