[bf1942] BF1942 linux auto restart

Reinder Gerritsen reinder at strikerz.net
Fri Feb 14 04:28:02 EST 2003


It is a simple way to do it, and it does do the job at hand...

However, this takes a risk. There is no failsafe for killing off the
service when it keeps on crashing, effectively stoping your system to
respond.

Make sure to build a time check into the loop that breaks out if there are
too many crashes within a limited timeframe. I have this put in my launch
script for the HL servers, and it has saved my ass already a number of
times when I was still running UT.
---------------------------------
#!/bin/sh
IDFILE="/var/run/<gametype>
if [ -f $IDFILE ]; then
	echo "this game is already running,"
	echo "or previous game shut down unexpectedly."
	exit 1
fi
failcount=0
while : ; do
	start=`date '+%d%H%M%S'`
	echo $start > $IDFILE

	<<<< Command syntax for the game >>>>

	stop=`date '+%d%H%M%S'`
	t=`expr $stop - $start`
	if test 0 -le $t -a $t -lt 20 ; then
		failcount=`expr $failcount + 1`
	    else
                failcount=0
	    fi
	    if test $failcount -gt 5 ; then
		exit 1
	    fi
	sleep 5
done
--------------------------------------
Another thing I put into this, is a "runfile". If for some reason, a fault
in the server brings my box down, the rc.local startscript notices
something was wrong, and will abort a launch of the game, so that I will
not lose control over the box.

I'd rather have the gameserver shit itself then shitting my system. It's a
rather nasty drive up to the Co-location in the middle of the night to
pull the box back up again. Just put it in an endless loop without any
failsafe is rather unpleasant.

Grtz.
Fox.

On Fri, 14 Feb 2003, DLinkOZ wrote:

> Use a loop
>
>
> while true
> do
> <insert your command line to start your server here>
> sleep 5
> done
>
>
>
> ----- Original Message -----
> From: "Richard Arnold" <spectraldeath at hotmail.com>
> To: <bf1942 at icculus.org>
> Sent: Thursday, February 13, 2003 4:47 PM
> Subject: [bf1942] BF1942 linux auto restart
>
>
> > Im looking for a way to auto-restart my linux server on a crash .
> > Does anyone have a good script for this ?
> >
> >
> >
> >
> >
> >
> >
> >
> > _________________________________________________________________
> > Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> > http://join.msn.com/?page=features/junkmail
> >
> >
>
>




More information about the Bf1942 mailing list