Skip to content

Instantly share code, notes, and snippets.

@navix
Forked from xi4oh4o/auto_restart_webserver.sh
Last active September 10, 2015 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navix/c420069bc9d81f4c964f to your computer and use it in GitHub Desktop.
Save navix/c420069bc9d81f4c964f to your computer and use it in GitHub Desktop.
Auto restart phpfpm on 502 & 504 Error also save logs
#!/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