10

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.

2 Answers 2

11

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
Sign up to request clarification or add additional context in comments.

2 Comments

but what about php artisan queue:listen, the main question was that
This does answer the question, although indirectly. php artisan queue:listen will run for a while (I can't remember the time out) and then exit. This is a limitation of PHP. Once it stops, no more jobs will be executed. To get around this, install supervisor as the answer suggests - supervisor will watch the queue:listen process and will restart it when it fails.
0

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.

1 Comment

Won't this spawn a new process every time the scheduler runs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.