Sometimes my whole Django based site goes into 504 gateway timeout errors so none page can be displayed.
Is it possible to write a shell program and cronjob it run every 5 minutes to detect such errors and restart FastCGI process if needed?
I'm currently using command below to restart FastCGI in case it's crashed but it doesn't work for above situation because when 504 gateway errors occur, the processes are still running.
ps ax | grep -v grep | grep port=8001 > /dev/null || restart_fcgi.sh