@@ -49,13 +49,6 @@ class Worker
4949 */
5050 public $ shouldQuit = false ;
5151
52- /**
53- * Indicates if the worker should stop.
54- *
55- * @var bool
56- */
57- public $ shouldStop = false ;
58-
5952 /**
6053 * Indicates if the worker is paused.
6154 *
@@ -205,8 +198,6 @@ protected function stopIfNecessary(WorkerOptions $options, $lastRestart)
205198 $ this ->stop (12 );
206199 } elseif ($ this ->queueShouldRestart ($ lastRestart )) {
207200 $ this ->stop ();
208- } elseif ($ this ->shouldStop ) {
209- $ this ->stop (1 );
210201 }
211202 }
212203
@@ -252,7 +243,7 @@ protected function getNextJob($connection, $queue)
252243 } catch (Exception $ e ) {
253244 $ this ->exceptions ->report ($ e );
254245
255- $ this ->handleException ($ e );
246+ $ this ->stopWorkerIfLostConnection ($ e );
256247 } catch (Throwable $ e ) {
257248 $ this ->exceptions ->report (new FatalThrowableError ($ e ));
258249 }
@@ -273,22 +264,22 @@ protected function runJob($job, $connectionName, WorkerOptions $options)
273264 } catch (Exception $ e ) {
274265 $ this ->exceptions ->report ($ e );
275266
276- $ this ->handleException ($ e );
267+ $ this ->stopWorkerIfLostConnection ($ e );
277268 } catch (Throwable $ e ) {
278269 $ this ->exceptions ->report (new FatalThrowableError ($ e ));
279270 }
280271 }
281272
282273 /**
283- * Handle a serious job exception .
274+ * Stop the worker if we have lost connection to a database .
284275 *
285276 * @param \Exception $e
286277 * @return void
287278 */
288- protected function handleException ($ e )
279+ protected function stopWorkerIfLostConnection ($ e )
289280 {
290281 if ($ this ->causedByLostConnection ($ e )) {
291- $ this ->shouldStop = true ;
282+ $ this ->shouldQuit = true ;
292283 }
293284 }
294285
0 commit comments