Game Development Community

Running ded server on Linux as a service

by Christopher Lohman · in ThinkTanks · 05/25/2003 (5:39 pm) · 6 replies

Does anyone have any working inet.d or xinetd scripts that I could use to run a TT ded server as a service on my RedHat server? (Want to run as a service so that it will start automatically when it reboots and restart if it dies)

#1
05/27/2003 (12:47 pm)
If there is no inet script then how is the ded server setup on the HomeLAN machines?
#2
05/27/2003 (1:51 pm)
..
im sure this would not be a problem to write yourself.
I've not set this up as a service tho I have setup others.

If you need help getting a service running I can do that.

just fire a script that does the restart if dead.
#3
05/27/2003 (8:15 pm)
Hey Chris,

The homelan servers run gentoo, and I have a gentoo init.d script that starts them up. I thought I sent this to you already? Have you tried adapting it to redhat?

- jq
#4
05/28/2003 (5:09 am)
Hey John: What I have from you was a single command that starts/restarts with nohup and dumps the output to /dev/null; but I can't find an email with any init.d script.

While I've been waiting for a response I decided to try to do it myself and have made some progress. I've succeeded in making it start as a service but I can't figure out how to get the stop to work. I would appreciate it if someone could help me over the last hurdle and provide any feedback on what I have so far:

#!/bin/sh
# processname: thinktanks
# chkconfig: 345 95 5
# description:  ThinkTanks Dedicated Server

# Source function library.
. /etc/rc.d/init.d/functions

PATH="$PATH:/usr/local/sbin:/usr/local/games/ThinkTanks"
MISSION="-mission RED"
GAME="-game TS $*"

case "" in
        start)
                echo -n "Starting ThinkTanks: "
                 /usr/local/games/ThinkTanks/thinktanksdedicated $MISSION $GAME
                echo
                touch /var/lock/subsys/thinktanks
                ;;
        stop)
                echo -n "Shutting down ThinkTanks: "
                killproc thinktanks
                echo
                rm -f /var/lock/subsys/thinktanks
                ;;
        restart)
                [[62822f080de92]] stop
                [[62822f080de92]] start
                ;;
        *)
                echo -n "Usage: [[62822f080de92]] {start|stop|restart"
esac


exit 0
#5
05/28/2003 (7:57 am)
In my stop script I just kill the process. It isn't the best way to stop it but it works. The start script writes out the pid of the server, so this is used when it is stopped.

Here is the gentoo startup script:

#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later

depend() 
{
    need net
}

#checkconfig() 
#{
#    if [ ! -e /etc/conf.d/thinktanks ] ; then
#	eerror "You need an /etc/conf.d/thinktanks file to run thinktanks"
#	return 1
#    fi
#}

USER=orbz

start_instance()
{
    DIR=
    SCRIPT= 

    einfo "  Starting instance: $DIR"
    start-stop-daemon --start \
	--pidfile $DIR/thinktanks.pid -x /usr/bin/screen \
	--make-pidfile --background \
	--startas /usr/bin/screen --chuid $USER \
	-- -D -m $DIR/$SCRIPT -nohomedir -respawn
}

stop_instance()
{
    DIR=

    einfo "  Stopping instance: $DIR"
    start-stop-daemon --stop --oknodo \
	--pidfile $DIR/thinktanks.pid -x /usr/bin/screen 
}

start() 
{
    #checkconfig || return 1
    ebegin "Starting thinktanks servers"
    start_instance /homelan/orbz/ThinkTanks-1 "thinktanksdedicated -mission GREEN -game B"
    sleep 1 # isn't necessary but yields predictable udb bind order
    start_instance /homelan/orbz/ThinkTanks-2 "thinktanksdedicated -mission RED -game TS"
    sleep 1
    eend $?
}

stop() 
{
    ebegin "Stopping thinktanks servers"
    stop_instance /homelan/orbz/ThinkTanks-1
    stop_instance /homelan/orbz/ThinkTanks-2
    eend $?
}
#6
06/04/2003 (4:09 pm)
Jeez, and I can't even figure out how to get the dedicated server up and running. Maybe I did get in over my head.
<--- Linux Newbie
If anyone is willing and has time, could you post the process for getting the server up and running? Hopefully, if all goes well I will have another machine to occupy my time and expect to have the absolute best ping. :P
Hatter