简体   繁体   English

Laravel Worker似乎没有停止

[英]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. 我在我的数据库中有一个作业列表,当我运行php artisan queue:work database ,它处理每个作业但是一旦处理完最后一个作业,它似乎就不会停止。 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: 如果希望工作程序在运行一个作业后退出,请添加--once选项:

$ 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: 从5.7开始,您可以使用--stop-when-empty来处理队列中的所有作业,然后退出:

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

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

Note: The default behavior changed around Laravel 5.3. 注意:Laravel 5.3周围的默认行为已更改。 Previously a worker would process one job and exit; 以前工人会处理一份工作并退出; it only continued running if the --daemon option had been used. 如果使用了--daemon选项,它只会继续运行。 After 5.3 this became the default behavior, and --daemon was deprecated. 5.3之后,这成为默认行为,并且不推荐使用--daemon

Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal. 请注意,一旦queue:work命令启动,它将继续运行,直到手动停止或关闭终端。 Using the --once option will not resolve your problem. 使用--once选项无法解决您的问题。 Check laravel documentation for more. 查看laravel文档了解更多信息。

The documentation says: The --once option may be used to instruct the worker to only process a single job from the queue. 文档说:--once选项可用于指示worker只处理队列中的单个作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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