Laravel队列如何工作以及如果php artisan queue:listen停止怎么办 [英] How does Laravel queue work and what if php artisan queue:listen stops
问题描述
我已经安装了beanstaled,并且可以与laravel一起正常工作.让我感到困惑的是,我们必须要做
I have installed beanstaled and its working fine with laravel. The point where I am puzzled is that we have to do
php artisan queue:listen
开始监听队列.现在,我正在通过腻子远程在 amazone ec2 实例上使用它.但是我关闭的终端是什么?通过代码创建的作业会起作用吗?是一直手动调用 php artisan queue:listen
还是 php artisan queue:work
.这似乎不公平.
to start listening queue. Right now, I am using it on amazone ec2 instance remotely through putty. but what is i close terminal? Will the jobs created through the code will work? Is it manually calling php artisan queue:listen
or php artisan queue:work
all time. Which does not seems fair.
如果 php artisan queue:listen
完成一次,即使关闭终端,它还会继续运行吗?
If once php artisan queue:listen
done, will it keep on running even if we close terminal?
实际上我不知道.
推荐答案
您还需要安装超级用户.这是有关在laravel中使用beantalkd的教程:
you need to install supervisor also. Here is a tutorial on using beanstalkd with laravel:
http://fideloper.com/ubuntu-beanstalkd-and-laravel4
以下是有关主管的详细信息:
Here are details on supervisor also:
http://supervisord.org/installing.html
我个人使用redis实例,并从那里与主管一起运行我的队列.我发现它的记忆力要比个人聊天有效,但每个人都有.
I personally use a redis instance and run my queue with supervisor from there. I find its a bit more memory effective then beanstalkd personally but each to there own.
主管将执行来自工匠的queue:listen命令,这将运行一个作业,如果您有多个主管进程,则可以在订单项中运行多个.根据您的操作,我几乎会考虑使用python和multithereading,因为我将其用于一些我以前用于队列的事情,并且它甚至提供了更好的结果.
Supervisor will execute the queue:listen command from artisan and this will run a job, if you have multiple supervisor processes then you can run multiple in line items. depending on what you are doing i would almost look into python and multithereading also as i have used this for a few things i used to use a queue for and it has provided even better results.
主管的示例配置文件:
[program:myqueue]
command=php artisan queue:listen --env=your_environment
directory=/path/to/laravel
stdout_logfile=/path/to/laravel/app/storage/logs/myqueue_supervisord.log
redirect_stderr=true
autostart=true
autorestart=true
这篇关于Laravel队列如何工作以及如果php artisan queue:listen停止怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!