使用supervisor管理php-fpm时遇到的问题

supervisor的配置如下:

1 [program:php7-fpm]
2 command=/usr/local/php-7.1.3/sbin/php-fpm -y /usr/local/php-7.1.3/etc/php-fpm.conf -c /usr/local/php-7.1.3/lib/php.ini
3 directory=/root
4 autostart=true
5 autorestart=true
6 startretries=3
7 stderr_logfile=/var/log/supervisor/php7-fpm.err.log
8 stdout_logfile=/var/log/supervisor/php7-fpm.out.log
9 user=root

在启动的时候虽然php-fpm有启动,但supervisor总是报错,提示启动失败,错误日志如下:

2017-03-25 14:12:41,732 INFO spawned: 'php7-fpm' with pid 29351
2017-03-25 14:12:41,774 INFO exited: php7-fpm (exit status 0; not expected)
2017-03-25 14:12:42,776 INFO spawned: 'php7-fpm' with pid 29359
2017-03-25 14:12:42,814 INFO exited: php7-fpm (exit status 70; not expected)
2017-03-25 14:12:44,818 INFO spawned: 'php7-fpm' with pid 29361
2017-03-25 14:12:44,840 INFO exited: php7-fpm (exit status 70; not expected)
2017-03-25 14:12:47,845 INFO spawned: 'php7-fpm' with pid 29363
2017-03-25 14:12:47,867 INFO exited: php7-fpm (exit status 70; not expected)
2017-03-25 14:12:48,869 INFO gave up: php7-fpm entered FATAL state, too many start retries too quickly

翻看supervisor的文档时发现了如下描述:

Controlled programs should themselves not be daemons, as supervisord assumes it is responsible for daemonizing its subprocesses (see Nondaemonizing of Subprocesses).

于是将php-fpm.conf中的配置修改如下:

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = no

再次使用supervisor启动php-fpm成功:

supervisorctl start php7-fpm
php7-fpm: started

 

posted on 2017-03-25 22:43  古道倦马  阅读(4286)  评论(0编辑  收藏  举报

导航