You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/RequestInsurance/RequestInsuranceWorker.php
+26-3Lines changed: 26 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ public function run(bool $runOnlyOnce = false): void
69
69
70
70
do {
71
71
try {
72
+
$this->registerTimeoutHandler();
73
+
72
74
if (Config::get('request-insurance.useDbReconnect')) {
73
75
DB::reconnect();
74
76
}
@@ -84,16 +86,18 @@ public function run(bool $runOnlyOnce = false): void
84
86
85
87
usleep($waitTime);
86
88
} catch (Throwable$throwable) {
89
+
$this->resetTimeoutHandler(); // We need to reset here before logging the error and sleeping, otherwise the timeout handler might trigger while we are sleeping/logging, which is not desirable.
90
+
87
91
Log::error($throwable);
88
92
89
93
if ($runOnlyOnce) {
90
94
throw$throwable;
91
95
}
92
96
93
-
sleep(5); // Sleep to avoid spamming the log
97
+
usleep(100_000); // Sleep to avoid spamming the log
98
+
} finally {
99
+
$this->resetTimeoutHandler();
94
100
}
95
-
96
-
pcntl_signal_dispatch();
97
101
} while ( ! $runOnlyOnce && ! $this->shutdownSignalReceived);
98
102
99
103
Log::info(sprintf('RequestInsurance Worker (#%s) has gracefully stopped', $this->runningHash));
@@ -107,6 +111,7 @@ public function run(bool $runOnlyOnce = false): void
0 commit comments