报错问题一般如下两点
1、php-fpm相关配置问题
2、资源耗尽问题
在此
编写如下脚本进行巡检,当有问题自动检查并重启php-fpm假死状态释放资源
# vim php-fpm_restart.sh
#!/bin/sh
#变量初始化
process="php-fpm"
startservice="systemctl start php-fpm.service"
down=0
#判断语句
while true
do
#获取http状态码
code=$(curl -H "Host:www.jiangjj.com" -m 5 -L -s -w %{http_code} http://127.0.0.1 -o /dev/null)
#判断状态码返回000或大于等于500时,计数故障到down变量
if [ $code -eq 000 -o $code -ge 500 ];then
((down++));
else
break
fi
#等待5s
sleep 5
#判断是否检查三次都标记为故障
if [ $down -ge 3 ];then
if [ "$(find /tmp/${process}_restart -mmin -3)" == ""];then
#获取进程名对应的所有pid
pids=$(ps -aux | grep ${process} | grep -v "grep" | awk '{print $2}')
#依次对所有pid执行kill命令
for jiangjj in $pids;do
kill -9 $jiangjj
kill -9 $jiangjj
done
#kill完pid后启动服务
$startservice
echo "$(date) Return code $code,${process} had been restarted" >> /tmp/${process}_restart
else
echo "$(date) ${process} not yet recobery,As it hsd been restarted in 2 minutes.so this time ignore."
fi
break
fi
done
#授权
# chmod u+x php-fpm_restart.sh
#执行crontab定时任务即可