How does Laravel queue work and what if php artisan queue:listen stops

南笙酒味 提交于 2021-02-06 10:48:09

问题


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

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.

If once php artisan queue:listen done, will it keep on running even if we close terminal?

Actually I dont know.


回答1:


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

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.

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.

example config file for supervisor:

[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



回答2:


You can also make use of Laravel's Task Scheduler i.e add the php artisan queue:listen command to the scheduler and sets its frequency to whatever you wants.

So that will make sure to call queue listen process automatically.

Hope it will make sense.



来源:https://stackoverflow.com/questions/27601634/how-does-laravel-queue-work-and-what-if-php-artisan-queuelisten-stops

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!