最近nginx间隙性的出现502错误,如何实现自动重启php-fpm呢
想到的解决方案
1、使用crontab定时执行shell脚本,出现错误后重启(每5秒定时执行)
2、使用nohup,shell脚本后台执行
示例脚本
#!/bin/bash
while :
do
URL="http://192.168.1.30"
RESULT=`curl -m 10 -I -s $URL | grep "HTTP/1.1 502"`
if [ -n "$RESULT" ]; then
/etc/init.d/php-fpm restart
fi
sleep 5
done
3、编写nginx模块,通过条件执行shell脚本
能想到的也就是这几种了,感觉这几种方案都不太好,谁有更好的解决方案?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
欢迎选择我的课程,让我们一起见证您的进步~~