如何执行 Laravel 作业(队列)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37067934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:43:55  来源:igfitidea点击:

How to execute laravel job (queue)?

phplaravellaravel-5

提问by lieroes

developers, I have a problem. My queue not working or i just not understand how it's works. I create a command which should add a new queue job. Driver for Queue is - database. After executing my command i see a new row in table 'jobs'. After that I try to do "php artisan queue:work" - but nothing happens.

开发人员,我有问题。我的队列不工作,或者我只是不明白它是如何工作的。我创建了一个命令,它应该添加一个新的队列作业。队列的驱动程序是 - 数据库。执行我的命令后,我在表“jobs”中看到了一个新行。之后,我尝试执行“php artisan queue:work” - 但没有任何反应。

Help me please, how can I execute this job?

请帮帮我,我该如何执行这项工作?

回答by Himanshu Bhandari

From the documentation: [Daemon Queue Listener] The queue:workartisan command includes a --daemonoption for forcing the queue worker to continue processing jobs without ever re-booting the framework. This results in a significant reduction of CPU usage when compared to the queue:listen command:

来自文档:[ Daemon Queue Listener] queue:workartisan 命令包括一个--daemon选项,用于强制队列工作器继续处理作业而无需重新启动框架。与 queue:listen 命令相比,这会显着降低 CPU 使用率:

To start a queue worker in daemon mode, use the --daemonflag:

要以守护进程模式启动队列工作器,请使用以下--daemon标志:

php artisan queue:work connection --daemon

However if you don't have multiple connections remove connection and execute it without connection :

但是,如果您没有多个连接,请删除连接并在没有连接的情况下执行它:

php artisan queue:work --daemon

It worked for me.

它对我有用。

回答by overburn

Try

尝试

php artisan queue:listen

php artisan queue:listen

instead.

反而。