加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php-fpm – logrotate导致php5-fpm停机

发布时间:2020-12-13 13:53:25 所属栏目:PHP教程 来源:网络整理
导读:我注意到我们的一台服务器在logrotate运行后才开始返回错误,即在nginx错误日志中我可以看到: [error] 8501#0: *118126869 recv() failed (104: Connection reset by peer) while reading response header from upstream,client: xxx.yyy.zz.ww,server: www.
我注意到我们的一台服务器在logrotate运行后才开始返回错误,即在nginx错误日志中我可以看到:

[error] 8501#0: *118126869 recv() failed (104: Connection reset by
peer) while reading response header from upstream,client: xxx.yyy.zz.ww,server: www.test.com,request: “GET /index.php HTTP/1.1”,upstream: “fastcgi://127.0.0.1:9011”,host: “www.test.com”

我尝试添加一个postrotate动作,使php重新加载优雅,但错误仍在发生,我们当前的logrotate如下:

/var/log/php5-fpm.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 644 root root
        postrotate
                [ ! -f /var/run/php5-fpm.pid ] || kill -USR2 `cat /var/run/php5-fpm.pid`
        endscript
}

PHP配置如下:

[www-9011]

user = www-data
group = www-data
listen = 127.0.0.1:9011
listen.backlog = 65535
pm = ondemand
pm.max_children = 50
pm.process_idle_timeout = 10s;
pm.max_requests = 500
rlimit_files = 16384
chdir = /
catch_workers_output = no
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on

我们正在运行ubuntu 12.04和php 5.3.10

发送USR1

https://github.com/php/php-src/blob/b7a7b1a624c97945c0aaa49d46ae996fc0bdb6bc/sapi/fpm/fpm/fpm_events.c#L94

源代码显示这是专门为旋转文件,我知道Ubuntu 14.04没有很好地处理fpm重载(USR2),我认为它也适用于旧版本.

所以改为

postrotate
                [ ! -f /var/run/php5-fpm.pid ] || kill -USR1 `cat /var/run/php5-fpm.pid`
endscript

简单地旋转日志

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读