[bf1942] server fail?

Jim McKibben jonny5 at socket.net
Fri Mar 7 02:46:45 EST 2003


I have a link set at my local.start that starts this this script

======code======
/opt/bf1942-lnxded-1.3beta/startbf
=====endcode=====

then the startbf script

======code======
cd /opt/bf1942-lnxded-1.3beta/
su jonny5 -c "screen -dmS bf /opt/bf1942-lnxded-1.3beta/bf_run"
=====endcode=====

then the bf_run script

======code======
#!/bin/sh
#
#       Copyright (c) 2002, Valve LLC. All rights reserved.
#
#       a wrapper script for the main hl dedicated server binary.
#       Performs auto-restarting of the server on crash. You can
#       extend this to log crashes and more.
#

BF=./bf1942_lnxded
TIMEOUT=10 # time to wait after a crash (in seconds)
CRASH_DEBUG_MSG="email debug.log to sdk at valvesoftware.com"
GDB="gdb" # the gdb binary to run
DEBUG_LOG="debug.log"

# uncomment this line if you want ctrl-c ignored
#trap "" SIGINT

# setup the libraries, local dir first!
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
if test -n "`echo $* | grep "\-norestart"`" ; then
        RESTART=""; # norestart defined, do do restarts
else
        RESTART="yes";
fi

DEBUG=`echo $* | grep "\-debug"`

if test -n "$DEBUG" ; then
        #turn on core dumps :) (if possible)
        echo "Enabling debug mode"
        if test "`ulimit -c`" -eq 0; then
                ulimit -c 2000
        fi
        GDB_TEST=`$GDB -v`
        if test -z "$GDB_TEST"; then
                echo "Please install gdb first."
                echo "goto http://www.gnu.org/software/gdb/ "
                DEBUG="" # turn off debugging cause gdb isn't installed
        fi

fi

if test -n "$RESTART" ; then
        echo "Auto-restarting the server on crash"

        #loop forever
        while true
        do

                # run the server :) the $* passes all the arguments
provided to the script 
                #  to the server binary
                $BF $*

                if test $? -eq 0; then
                        break; # the binary exited properly, usually due
to a "quit"
                fi

                if test -n "$DEBUG" ; then
                    if test -f core ; then # check a core was dumped
                        echo "bt" > debug.cmds;
                        echo "info locals" >> debug.cmds;
                        echo "info sharedlibrary" >> debug.cmds
                        echo "info frame" >> debug.cmds;  # works, but
gives an error... must be last
                        echo
"----------------------------------------------" >> $DEBUG_LOG
                        echo "CRASH: `date`" >> $DEBUG_LOG
                        $GDB $HL core -x debug.cmds -batch >> $DEBUG_LOG
                        echo "End of crash report" >> $DEBUG_LOG
                        echo
"----------------------------------------------" >> $DEBUG_LOG
                        echo $CRASH_DEBUG_MSG
                        rm debug.cmds
                    fi
                else
                        echo "Add \"-debug\" to the $0 command line to
generate a debug.log to help with solving this problem"
                fi

                echo "`date`: Server Died"
                sleep $TIMEOUT # don't thrash the hard disk if the
server dies, wait a little

        done # while true 
else
        exec $BF $*
fi

echo "`date`: Server Quit"
=====endcode=====

Yes, that last part is taken from the half life server start up
'hlds_run' which was originally make by Sierra.

thanks,
j0nny5
"be the ball danny"

-----Original Message-----
From: DLinkOZ [mailto:dlinkoz at oesm.org] 
Sent: Friday, March 07, 2003 1:04 AM
To: bf1942 at icculus.org
Subject: Re: [bf1942] server fail?

That's how I do mine, but being an init script started by root, you'll
want
to su it to a nonpriviledged user.


----- Original Message -----
From: "Aubrey King" <aking at gblx.net>
To: <bf1942 at icculus.org>
Sent: Friday, March 07, 2003 12:56 AM
Subject: Re: [bf1942] server fail?


>
> can one have a 'daemon' or initscript that launches screen and then
runs a
> command in it?  ie. 'screen -S /usr/local/bf1942_srv'?  I know that's
how
> I start pin eup.  Wonder if that will background.  I'll worry about
those
> hurdles once the server works on my box. ;)
>
> Aubrey King
> Global Crossing, Ltd.
> IP Systems Engineering
> Systems Administrator
>
> On Thu, 6 Mar 2003, Brad Davidson wrote:
>
> > Aubrey King said:
> > >
> > > Rather than screen, I may write an initscript for it to run at
boot.
I
> > > should make an rpm! :)
> >
> > The only problem that I see with that is that unlike most daemons
that
you
> > start on boot, the BF server doesn't fork off to the background, it
> > expects to stay in foreground. That and the fact that it restarts
itself
> > every time the map changes... that's why people use screen, so that
they
> > can detach and leave it running.
> >
> > > Well.. I followed the advice here, but it did
> > > not solve my problem.
> >
> > >From the messages you posted, it looks like it's loaded the map and
is
> > waiting for players. Have you tried connecting directly to the
server by
> > specifying the IP, as opposed to looking for it in the game list?
What
> > happens when you do?
> >
> >
> >
>
>










More information about the Bf1942 mailing list