Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Worker doesn't seem to stop

Tags:

php

laravel

I have a list of jobs in my database, when I run php artisan queue:work database, it processes each job but once it processes the last one, it doesn't seem to stop. I thought doing it this way would mean once the worker has no jobs left, it stops.

like image 979
JTP Avatar asked Sep 11 '25 13:09

JTP


1 Answers

Add the --once option if you want the worker to exit after running one job:

$ php artisan queue:work --once

As of 5.7 you can use --stop-when-empty to process all jobs in the queue and then exit:

$ php artisan queue:work --stop-when-empty

Docs: https://laravel.com/docs/5.7/queues#running-the-queue-worker

Note: The default behavior changed around Laravel 5.3. Previously a worker would process one job and exit; it only continued running if the --daemon option had been used. After 5.3 this became the default behavior, and --daemon was deprecated.

like image 65
Travis Britz Avatar answered Sep 13 '25 07:09

Travis Britz