php 进程卡死,出现502 bad gateway
网站突然出现502的错误, php 突然停止, 查日志并没看出什么问题, 写个自动重启php的脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash
if [ -e /var/lock/subsys/502 ]
then
killall -9 curl 2>/dev/null
killall -9 php-cgi 2>/dev/null
/etc/init.d/fastcgi start >/dev/null
echo "[ `date +'%h %d %T'` ] PHP-CGI died with no response, all processes restarted">>/php-cgi/log
else
touch /var/lock/subsys/502
if [ `curl --connect-timeout 5 -I http://youdomain.com/ 2>/dev/null | grep '502 Bad Gateway' -c` != '0' ]
then
killall -9 php-cgi 2>/dev/null
/etc/init.d/fastcgi start >/dev/null
echo "[ `date +'%h %d %T'` ] PHP-CGI died with 502 bad gateway, all processes restarted">>/php-cgi/log
fi
rm -f /var/lock/subsys/502
fi |
加入自动任务每分钟运行一次就可以了
