-
-
Save kimtrien/e21e36bdbc00674ea27373528c0e2ddf to your computer and use it in GitHub Desktop.
Auto restart phpfpm on 502 & 504 Error also save logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MY_URL="http://moefou.org" #change you website | |
RESULT_502=`curl -I $MY_URL|grep "HTTP/1.1 502"` | |
RESULT_504=`curl -I $MY_URL|grep "HTTP/1.1 504"` | |
if [ -n "$RESULT_502" ]; then | |
killall php-fpm;php-fpm | |
date>>/data/logs/web_error.log;echo "502 Bad Gateway">>/data/logs/web_error.log | |
elif [ -n "$RESULT_504" ]; then | |
killall php-fpm;php-fpm | |
date>>/data/logs/web_error.log;echo "504 Gateway Time-out">>/data/logs/web_error.log | |
fi | |
: << \EOF | |
run crontab -e | |
add below | |
#Auto Fix WebServer 502 & 504 Error | |
#* * * * * root /data/task/auto_restart_webserver.sh >/dev/null 2>&1 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment