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

查看:38
本文介绍了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?

推荐答案

Edit updated 2017-04-07:

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

There are now three ways to run your queue:

  • queue:work - 这是新的守护进程"进程(不再需要该标志).该框架将启动一次" - 然后继续循环遍历作业.这将无限期地持续下去.它使用的内存/cpu 比 queue:listen 少,因为框架一直处于运行状态.您还必须记住使用 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天全站免登陆