Stopping a Laravel Queue after it has finished running

3.3k views Asked by At

I am running a web application on Laravel 5.5. I have a requirement to run the jobs in a queue and then stop the queue. The queue cannot be allowed to stay running.

I am running the below command but this just endlessly carries on.

php artisan queue:work --tries=3

If I use supervisord can I stop the queue from inside the Laravel application.

Any help is really appreciated.

1

There are 1 answers

3
Giovanni S On

From the documentation:

Processing All Queued Jobs & Then Exiting

The --stop-when-empty option may be used to instruct the worker to process all jobs and then exit gracefully. This option can be useful when working Laravel queues within a Docker container if you wish to shutdown the container after the queue is empty:

Try php artisan queue:work --tries=3 --stop-when-empty

https://laravel.com/docs/8.x/queues#running-the-queue-worker