In order to process large numbers of jobs, I run a variable number of queue workers depending on howmuch work there is to complete. I don\'t want to run more workers than ar
Since Laravel 5.5 there is an event called Illuminate\Queue\Events\Looping
that gets fired from the daemonShouldRun()
call inside the main worker loop of Illuminate\Queue\Worker
. So if you setup a listener to do your should process jobs check, and return false then the queue worker(s) will stop until the check returns true. There's a sleep between the next time it checks it which you can customise by passing --sleep
to the queue:work command.
I'm currently using this technique during deployments to stop workers which run inside docker containers, as it's not so easy to run the suggested queue:restart
on them without hacking around.