Nyx*_*nyx 7 php laravel symfony-components laravel-4
我跑了php artisan queue:listen大约27分钟后,它停止处理更多的工作.在我的错误日志中,我看到错误:
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}
Run Code Online (Sandbox Code Playgroud)

这是一个错误吗?我不认为听众应该超时!
第二轮听众在3小时后超时.我用php-fgm在nginx上运行Laravel 4.
无论你设置多长时间,它最终会耗尽内存或超时.您可以使用主管来保持其运行.它非常简单易用.
首先安装它:
sudo apt-get install supervisor
Run Code Online (Sandbox Code Playgroud)
或使用其网站上列出的方法,如easy_install http://supervisord.org/installing.html
现在为主管添加配置文件.打开/etc/supervisor/conf.d/queue.conf(或任何你想要命名文件但放入的文件/etc/supervisor/conf.d/)并添加:
[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
Run Code Online (Sandbox Code Playgroud)
以上解释:program:_____我们如何命名运行的内容.我们稍后会参考.command是您要运行的命令.directory是它应该运行的地方.在我的情况下,我在一个名为"laravel"的项目中.stdout_logfile是您要重定向从命令接收的stdout的文件.redirect_stderr设置为true以将所有错误指向stdout_logfile您指定的同一日志,您也可以将这些错误设置为自己的日志文件.
打开主管控制器:
sudo supervisorctl
Run Code Online (Sandbox Code Playgroud)
阅读/etc/supervisor/conf.d/目录的内容 :(仍然在supervisorctrl中)
reread
Run Code Online (Sandbox Code Playgroud)
将队列程序添加到主管:
add queue
Run Code Online (Sandbox Code Playgroud)
而已.现在它应该运行.如果您在日志文件中查找错误以查看错误.
重新启动服务器后,您将不得不再次启动主管sudo service supervisor start.
Laracasts非常适合主管.如果您没有订阅Laracasts,我强烈推荐它.
queue:listen在Laravel 4有一个--timeout选项.如果您想要无限制超时,则应将--timeout选项设置为0.
./artisan queue:listen --timeout=0
Run Code Online (Sandbox Code Playgroud)
小智 0
问题是有时间限制。
更改时间限制,问题就解决了。
set_time_limit(需要多少秒)
http://php.net/manual/en/function.set-time-limit.php