Im not sure how to go about checking the server to see if it is still running. I would like to have a start script that can every few minutes check to make sure that it is still running and restart it if necessary.
Please advise.
Advertisement
Page 1 of 1
Script to check and restart server if crashed
I need one...
#2
Posted 01 October 2013 - 08:10 AM
I found this solution, I hope it works:
You can slow down the speed of the script just adding "sleep SECONDS" at the begin or at the end of the script (like in the example), selecting the amount of time.
#!/bin/bash
while [ ! false ]
do
# sleep 120 (120 seconds)
ps cax | grep Quake3
if [ $? -eq 0 ]; then
echo "Process is running."
# doing nothing...
else
echo "Process is not running."
# restart the game: /path/to/game +parameters
fi
# sleep 120 (2 minutes)
done
You can slow down the speed of the script just adding "sleep SECONDS" at the begin or at the end of the script (like in the example), selecting the amount of time.
This post has been edited by UnlessMe: 01 October 2013 - 08:14 AM
#3
Posted 01 October 2013 - 07:21 PM
In the support section theres another version of a restart script, following a cleaner approach by relying on the fact that starting the urt server is a "blocking call".
The following is basically the same script.. modified to copy the last couple of lines from your qconsole.log to your crash.log and to update symlinks used for custommaps to the q3ut4 and appropriate webspace folder.
The only problem with those scripts is, that there's some errors which don't seem to terminate the urt process, which in both cases renders the whole effort useless. Nevertheless, if you're going for something more elaborate, here's a more comprehensive example of a quake 3 start script, which also kinda justifies scheduling a task to restart if necessary.
The following is basically the same script.. modified to copy the last couple of lines from your qconsole.log to your crash.log and to update symlinks used for custommaps to the q3ut4 and appropriate webspace folder.
#!/bin/bash
SELF=`readlink -f $0` # getting the script's location
DIR=`dirname $SELF` # since this is to be saved in the urt gamefolder
CRASHLOG=/path/to/your/desired/crash.log # path to your desired crash.log
CONSOLELOG=/path/to/your/qconsole.log # path to qconsole.log
CUSTOMMAPDIR=/path/to/your/custommapsfolder # path to your custom maps
WEBSERVERMAPDIR=/path/to/your/webservers/maps/folder/incase/you/got/one/q3ut4 # path to your local dlurl folder
declare -a updatelocs
updatelocs[0]=$DIR/q3ut4
updatelocs[1]=$WEBSERVERMAPDIR
while true; do
# next loop will delete all symlinks in ur updatelocs folder
# think of this incase you got other symlinks there, but
# those for custom maps
for updateloc in ${updatelocs[*]}; do
find $updateloc -maxdepth 1 -lname '*' -exec rm {} \;
for map in $CUSTOMMAPDIR/*; do
ln -s -t $updateloc $map
done
done
# starting the server
$DIR/Quake3-UrT-Ded.x86_64 +exec server.cfg
# server terminated ..
echo -e "SHUTDOWN: "`date`"\r\n###################################################################" >> $CRASHLOG
tail -30 $CONSOLELOG >> $CRASHLOG
echo -e "###################################################################\r\n\r\n\r\n" >> $CRASHLOG
done
The only problem with those scripts is, that there's some errors which don't seem to terminate the urt process, which in both cases renders the whole effort useless. Nevertheless, if you're going for something more elaborate, here's a more comprehensive example of a quake 3 start script, which also kinda justifies scheduling a task to restart if necessary.
Page 1 of 1
Fast Reply
1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users
Advertisement