How does the Laravel queue work, and what if the php-artisan queue: listening stops

I installed beanstaled and work fine with laravel. What I'm puzzled with is what we have to do

php artisan queue:listen 

to start listening to the queue. Right now I am using it on an amazone ec2 instance remotely via putty. but what is this terminal? Will jobs created using code work? php artisan queue:listen or php artisan queue:work is manually called all the time. Which does not seem fair.

If once php artisan queue:listen done, will it continue to work even if we close the terminal?

Actually I do not know.

+8
php laravel-4
source share
2 answers

You also need to install a dispatcher. Here is a tutorial on using beanstalkd with laravel:

http://fideloper.com/ubuntu-beanstalkd-and-laravel4

The following is information about the dispatcher:

http://supervisord.org/installing.html

I personally use the redis instance and start the queue with the supervisor from there. I find it a little more efficient in terms of memory, and then beanstalkd personally, but each one is there.

Supervisor will execute the queue: listen command from artisan, and this will start the task, if you have several dispatcher processes, you can run several lines. depending on what you are doing, I would almost look into python and multithereading, since I used this for a few things that I used to use in the queue, and this provided even better results.

Example configuration file for a 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 
+11
source share

You can also use Laravel Task Scheduler . Add the php artisan queue:listen command to the scheduler and set its frequency according to what you want.

Thus, make sure that you call the queue listening process automatically.

Hope this makes sense.

0
source share

All Articles