#Process Name
process = 'server'
#Check running process/daemons
if ps ax | grep -v grep | grep $process
then
echo "$process Health check OK!"
else
echo "$process not found, restarting..."
/usr/local/bin/v2server/server #launch command or link to script to do the tasks the cgi does
fi
Two potential problems I see with an auto restart.
1) If I deliberately bring the game down for any reason (e.g. doing a data conversion etc...) I would need to remember to turn off this feature.
2) If the server crashes then the auto restart will not work. If needs to be a "foo" restart which writes to the terminal. In theory I have changed the server code to write to both the terminal and the log but it is not 100% reliable (not sure if this is an Apache only issue of something more fundamental as I have not really investigated the alternatives).
There is so much about Linux I have forgotten, or maybe never really knew.
I would need to look up how to do a 5 minute check.
Also I would need to somehow notify me that a crash and restart occurred.
They have a builder tool to make it super ez.
Can have it run on restart too.
*/5 * * * * <command> <<5 minute check.
@restart <command> <<If server crashes/restarts it will run on reboot.
#1 is valid it would keep bring it up lol
#2 can make it run any command in the job.
Depending on how u get notified atm, could include in the script to send an email or log fails to a file.
few diff tools u can install on linux box's
ssmtp lets u put it in the script, so if it hits the else it would run something like