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}
Is this a bug? I don't think the listener is supposed to time out!
A second run of the listener timed out after 3 hours. I'm running Laravel 4 on nginx with php-fgm.
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.
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
just run COMPOSER_PROCESS_TIMEOUT=4000 php artisan queue:listen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With