2017-03-20 15:19
浏览 127

Laravel + Beanstalkd:如何运行“queue:listen”作为服务

I'm using Beanstalkd as a work queue in my project.

Now, my project is completed and I have to deploy it on VPS(production server).

There is something that confusing me! should I ssh to production server and manually type php artisan queue:listen ? (it's crap)

Is there any server to run queue:listen as service?

图片转代码服务由CSDN问答提供 功能建议



有些东西让我感到困惑! 我应该ssh到生产服务器并手动输入 php artisan queue:listen ? (这是废话)

是否有任何服务器运行 queue:listen 作为服务?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dounianluo0086 2017-03-20 15:39

    You should use something like Supervisor to run the queue in production. This will allow you to run the process in the background, specify the number of workers you want processing queued jobs and restart the queue should the process fail.

    As for the queue you choose to use, that's up to you. In the past I've used Beanstalkd locally installed on an instance and Amazon SQS. The local instance was fine for basic email sending and other async tasks, SQS was great for when the message volume was massive and needed to scale. There are other SaaS products too such as IronMQ, but the usual reason people run into issues in production are because they're not using Supervisor.

    You can install Supervisor with apt-get. The following configuration is a good place to start:

    command=php /home/forge/ queue:work --sleep=3 --tries=3

    This will do the following:

    • Give the queue worker a unique name
    • Run the php artisan queue:work command
    • Automatically start the queue worker on system restart and automatically restart the queue workers should they fail
    • Run the queue worker across eight processes (this can be increased or reduced depending on your needs)
    • Log any output to /home/user/

    To start Supervisor, you'd run the following (after re-reading the configuration/restarting):

    sudo supervisorctl start laravel-worker:*

    The documentation gives you some more in-depth information about using Supervisor to run Laravel's queue processes.

    解决 无用
    打赏 举报

相关推荐 更多相似问题