Laravel 与主管排队 - 进入 FATAL 状态,太多启动重试太快
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50912491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel queues with Supervisor - Entered FATAL state, too many start retries too quickly
提问by Alexandre Thebaldi
I'm trying to use Laravel queues with supervisor but the service is not working properly. My /var/log/supervisor/supervisord.log
is:
我正在尝试将 Laravel 队列与主管一起使用,但该服务无法正常工作。我的/var/log/supervisor/supervisord.log
是:
2018-06-18 10:56:07,441 INFO spawned: 'laravel-worker_00' with pid 20838
2018-06-18 10:56:07,446 INFO spawned: 'laravel-worker_01' with pid 20839
2018-06-18 10:56:08,021 INFO exited: laravel-worker_01 (exit status 255; not expected)
2018-06-18 10:56:08,033 INFO gave up: laravel-worker_01 entered FATAL state, too many start retries too quickly
2018-06-18 10:56:08,033 INFO exited: laravel-worker_00 (exit status 255; not expected)
2018-06-18 10:56:09,034 INFO gave up: laravel-worker_00 entered FATAL state, too many start retries too quickly
My config /etc/supervisord.d/laravel-worker.conf
is:
我的配置/etc/supervisord.d/laravel-worker.conf
是:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/my-project/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=root:root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/my-project/worker.log
When I try to restart all programs:
当我尝试重新启动所有程序时:
$ sudo supervisorctl restart all
$ laravel-worker:laravel-worker_00: ERROR (abnormal termination)
$ laravel-worker:laravel-worker_01: ERROR (abnormal termination)
I'm a newbie with supervisor so someone can guide me?
我是主管的新手,所以有人可以指导我吗?
回答by DAMIEN JIANG
You need to add startsecs = 0
to your laravel-worker
config like so:
您需要像这样添加startsecs = 0
到laravel-worker
配置中:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/my-project/artisan queue:work --sleep=3 --tries=3
.....
startsecs = 0
startsecs
is default to 1s, if the program does not stay up for 1s it will see the startup as failure. Set it to 0 so the program needn't stay running for any particular amount of time. You can check this github issue for more info: https://github.com/Supervisor/supervisor/issues/212
startsecs
默认为 1 秒,如果程序没有停留 1 秒,它将看到启动失败。将它设置为 0,这样程序就不需要在任何特定的时间内保持运行。您可以查看此 github 问题以获取更多信息:https: //github.com/Supervisor/supervisor/issues/212
It would be better if you run the queue worker in daemon mode, use the --daemon flag: command=/usr/bin/php /var/www/my-project/artisan queue:work database --daemon --sleep=3 --tries=3
如果您在守护进程模式下运行队列工作者会更好,使用 --daemon 标志: command=/usr/bin/php /var/www/my-project/artisan queue:work database --daemon --sleep=3 --tries=3
After you change the config file, you may need to run supervisorctl reload
to allow the changes to take effect.
更改配置文件后,您可能需要运行supervisorctl reload
以使更改生效。
回答by Paolo
Just want to share my case.
只是想分享我的案例。
First, the user I used didn't have access to write to the log files so I added it as a sudo user.
首先,我使用的用户无权写入日志文件,因此我将其添加为 sudo 用户。
Second, now that Supervisor can write to the error log file, I saw that there was a parse error when trying to run the PHP script. I fixed the error and now Supervisor runs the script perfectly.
其次,既然 Supervisor 可以写入错误日志文件,我看到尝试运行 PHP 脚本时出现解析错误。我修复了错误,现在主管完美地运行了脚本。
Hope this helps someone too.
希望这对某人也有帮助。