Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

laravel-4

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.

like image 660
Rajan Rawal Avatar asked Dec 22 '14 11:12

Rajan Rawal


People also ask

How does queue work Laravel?

Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time.

What does php artisan queue restart do?

Running this simple command should do the trick: php artisan queue:restart. It works by setting a illuminate:queue:restart key in your cache store that holds the timestamp of when the command ran. After workers finish each job, they check for that key and see if it was updated since the last time they checked.

What is php artisan queue listen?

php artisan queue:listen. The queue:listen command simply runs the queue:work --once command inside an infinite loop, this will cause the following: An instance of the app is booted up on every loop. The assigned worker will pick a single job and execute it. The worker process will be killed.

How do I know if my Laravel queue is working?

Show activity on this post. This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.


1 Answers

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
like image 165
clonerworks Avatar answered Oct 11 '22 18:10

clonerworks