Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 Queue:listen times out

I ran php artisan queue:listen and after about 27 minutes, it stops processing any more jobs. In my error log, I see the error:

exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'The process timed out.' in /var/www/l4site/vendor/symfony/process/Symfony/Component/Process/Process.php:413
Stack trace:
#0 /var/www/l4site/vendor/symfony/process/Symfony/Component/Process/Process.php(201): Symfony\Component\Process\Process->wait(NULL)
#1 /var/www/l4site/vendor/laravel/framework/src/Illuminate/Queue/Listener.php(63): Symfony\Component\Process\Process->run()
#2 /var/www/l4site/vendor/laravel/framework/src/Illuminate/Queue/Listener.php(50): Illuminate\Queue\Listener->runProcess(Object(Symfony\Component\Process\Process), 128)
#3 /var/www/l4site/vendor/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php(69): Illuminate\Queue\Listener->listen(NULL, 'default', 0, 128, 60)
#4 /var/www/l4site/vendor/laravel/framework/src/Illuminate/Console/Command.php(108): Illuminate\Queue\Console\ListenCommand->fire()
#5 /var/www/l4site/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(240): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/l4site/vendor/laravel/framework/src/Illuminate/Console/Command.php(96): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/l4site/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/l4site/vendor/symfony/console/Symfony/Component/Console/Application.php(106): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/l4site/artisan(59): Symfony\Component\Console\Application->run()
#10 {main}

enter image description here

Is this a bug? I don't think the listener is supposed to time out!


Update

A second run of the listener timed out after 3 hours. I'm running Laravel 4 on nginx with php-fgm.

like image 528
Nyxynyx Avatar asked Apr 09 '13 01:04

Nyxynyx


3 Answers

Regardless of how long you have it set to it will eventually run out of memory or timeout. You can use supervisor to keep it running. It is really simple to use.

First Install it:

sudo apt-get install supervisor

or use a method listed on their site like easy_install http://supervisord.org/installing.html

Now add a config file for supervisor. Open /etc/supervisor/conf.d/queue.conf (or whatever you want to name the file but put it in /etc/supervisor/conf.d/) and add:

[program:queue]
command=php artisan queue:listen
directory=/var/www/laravel
stdout_logfile=/var/www/laravel/app/storage/logs/supervisor_queue_listener.log
redirect_stderr=true

Explanation of the above: program:_____ is how we name what is run. We will reference that later. command is the command you want to run. directory is where it should be run. In my case I am in a project called "laravel". stdout_logfile is the file where you want to redirect he stdout that is received from the command. redirect_stderr is set to true to direct all of the errors to the same log specified at stdout_logfile you can also set these to go to their own log file.

Open supervisor controller:

sudo supervisorctl

Read the contents of the /etc/supervisor/conf.d/ directory: (while still in supervisorctrl)

reread

Add the queue program to supervisor:

add queue

That's it. Now it should be running. If you have erros look in your log file to see what is wrong.

Once you restart your server you will have to start supervisor again with sudo service supervisor start.

Laracasts covers Supervisor really well. If you aren't subscribed to Laracasts I highly recommend it.

like image 69
DutGRIFF Avatar answered Oct 27 '22 00:10

DutGRIFF


queue:listen in Laravel 4 has a --timeout option. If you want an unlimited timeout you should set the --timeout option to 0.

./artisan queue:listen --timeout=0
like image 23
Tim Groeneveld Avatar answered Oct 26 '22 23:10

Tim Groeneveld


just run COMPOSER_PROCESS_TIMEOUT=4000 php artisan queue:listen

like image 43
sedigo Avatar answered Oct 26 '22 23:10

sedigo