我在运行作业队列侦听器时遇到超时(无限循环)。侦听器调用一个工作人员,其功能涉及使用shell_exec()
.
我正在使用 php5-fpm 和 PHP 框架 Laravel 4(它使用 symfony 组件)运行 nginx 1.2.7。
问题:运行一段时间后,监听器会退出并报错The process timed out
。我怀疑这是由于shell_exec()
返回结果需要很长时间。
尝试:我尝试将 nginx 上的超时设置增加到 600 秒,但这没有帮助。set_time_limit(0)
也无济于事。
如何防止它超时,或者至少防止超时错误杀死队列侦听器?
启用站点/mysite.com
server {
listen 80;
server_name www.mysite.com mysite.com *.mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/mysite/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
client_body_timeout 600;
send_timeout 600;
proxy_read_timeout 600;
}
}
错误堆栈跟踪
exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'The process timed out.' in /var/www/mysite/vendor/symfony/process/Symfony/Component/Process/Process.php:413
Stack trace:
#0 /var/www/mysite/vendor/symfony/process/Symfony/Component/Process/Process.php(201): Symfony\Component\Process\Process->wait(NULL)
#1 /var/www/mysite/vendor/laravel/framework/src/Illuminate/Queue/Listener.php(63): Symfony\Component\Process\Process->run()
#2 /var/www/mysite/vendor/laravel/framework/src/Illuminate/Queue/Listener.php(50): Illuminate\Queue\Listener->runProcess(Object(Symfony\Component\Process\Process), 128)
#3 /var/www/mysite/vendor/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php(69): Illuminate\Queue\Listener->listen(NULL, 'default', 0, 128, 60)
#4 /var/www/mysite/vendor/laravel/framework/src/Illuminate/Console/Command.php(108): Illuminate\Queue\Console\ListenCommand->fire()
#5 /var/www/mysite/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/mysite/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/mysite/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/mysite/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/mysite/artisan(59): Symfony\Component\Console\Application->run()
#10 {main}
更新
使用 Apache 2.2.22 和默认设置时仍然会发生超时。任何想法可以更改哪些设置以避免超时?