简体   繁体   中英

Laravel Worker doesn't seem to stop

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.

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.

Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal. Using the --once option will not resolve your problem. Check laravel documentation for more.

The documentation says: The --once option may be used to instruct the worker to only process a single job from the queue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM