What is the difference queue:work and queue:listen

前端 未结 4 1324
终归单人心
终归单人心 2020-12-29 20:11

I can\'t understand what\'s the difference between Laravel queue:work and Laravel queue:listen

I can see that:

  • Queue: Listen
4条回答
  •  無奈伤痛
    2020-12-29 20:36

    There are two different issues listed.

    There is artisan queue:work and artisan 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. 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.

    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.

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

提交回复
热议问题