Register  |  FAQ  |  Search  |  Memberlist  |  Usergroups  |  Log in 
Reply to topic
 Auto restart cron job? 
Drink
Major
Major

Joined: 01 Sep 2016
Posts: 158
Reply with quote
Hey LL,

Great that others can restart it now.
Poor lazy being bugged all the time on discord ;p

Could this now be done with a server side check tho?
Make it check every say 5 or 10minutes.

Code:
#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
View user's profile Send private message
  
Lordlava
Greater God
Greater God

Joined: 16 Mar 2016
Posts: 1558
Location: The Land Down Under
Reply with quote
Curious and a great idea.

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.


What do you think?

_________________
The Lord of Molten Rocks
View user's profile Send private message
  
Drink
Major
Major

Joined: 01 Sep 2016
Posts: 158
Reply with quote
https://ostechnix.com/a-beginners-guide-to-cron-jobs

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 Razz 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

sendmail Lordlava@gmail.com < Emailmessage.txt
View user's profile Send private message
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic