queue:work --daemon和queue:listen有什么区别 [英] What is the difference between queue:work --daemon and queue:listen

查看:181
本文介绍了queue:work --daemon和queue:listen有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置我的离线作业服务器.我已经阅读了文档,但仍然没有真正看到这两个命令之间的区别:artisan queue:work --daemonartisan queue:listen.我应该使用哪个命令来运行守护程序?

I'm settin up my offline job server. I've read the documentation but I still don't really see the differences between the two commands: artisan queue:work --daemon and artisan queue:listen. Which command should I use for running my daemons?

推荐答案

编辑更新于2017-04-07:

现在有三种运行队列的方法:

There are now three ways to run your queue:

  • queue:work-这是新的守护程序"进程(不再需要该标志).该框架将一次"启动-然后继续循环执行这些作业.这将无限期地继续下去.与框架queue:listen相比,它使用更少的内存/cpu,因为框架会一直保持运行状态.您还必须记住使用queue:restart强制队列更新在修补过程中推送的所有代码更改.

  • queue:work - this is the new "daemon" process (the flag is no longer required). The framework will fire up "once" - and then keep looping through the jobs. This will continue indefinitely. It uses less memory/cpu than queue:listen because the framework stays up the entire time. You must also remember to use queue:restart to force the queue to update any code changes you push during patching.

queue:work --once-这将启动框架,处理一项作业,然后关闭.在开发等过程中进行测试很有用.

queue:work --once - this will fire up the framework, process one job, then shutdown. Useful for testing during development etc.

queue:listen-这将在每个周期启动框架,处理一个作业,然后完全关闭,然后再次启动框架,并无限期循环.这意味着在处理每个作业后释放所有内存/进程.如果您使用queue:work导致内存泄漏,请尝试一下.

queue:listen - this will fire the framework up on every cycle, process one job, then fully shutdown, and then fire the framework up again etc and loop indefinitely. This means all memory/processes are released after each job is processed. If you have memory leaks with queue:work - give this a try.

--daemon标志不再对这些命令有影响.

The --daemon flag no longer has an effect on these commands.

原始答案:

列出了两个不同的问题.

There are two different issues listed.

artisan queue:workartisan queue:listen

  • queue:work将仅弹出队列中的下一个作业,并仅处理该作业.这是一个一次性"命令,一旦处理了一个队列命令,该命令将返回到命令提示符.
  • queue:listen将侦听队列,并继续处理收到的任何队列命令.这将无限期继续运行,直到您停止它为止.
  • queue:work will simply pop off the next job in the queue, and process only that one job. This is a 'one off' command that will return to the command prompt once the one queue command is processed.
  • queue:listen will listen to the queue, and continue to process any queue commands it receives. This will continue running indefinitely until you stop it.

在Laravel> = 4.2中,添加了--daemon命令.它的工作方式是直接保持队列直接运行,而不是在处理完每个队列后重新启动整个框架.这是一个可选命令,可以显着减少队列的内存和CPU需求.

In Laravel >=4.2 there was a --daemon command added. The way it works is simply keeps running the queues directly, rather than rebooting the entire framework after every queue is processed. This is an optional command that significantly reduces the memory and cpu requirements of your queue.

--daemon命令的重点是,在升级应用程序时,您需要使用queue:restart专门重新启动队列,否则您可能会遇到各种奇怪的错误,因为您的队列仍旧内存中的代码.

The important point with the --daemon command is that when you upgrade your application, you need to specifically restart your queue with queue:restart, otherwise you could potentially get all sorts of strange errors as your queue would still have the old code in memory.

因此回答您的问题"我应该使用哪个命令来运行守护程序?"-答案几乎总是queue:work --daemon

So to answer your question "Which command should I use for running my daemons?" - the answer is almost always queue:work --daemon

这篇关于queue:work --daemon和queue:listen有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆