SRCDS Steam group


Auto Restart, Update, and Keep Alive Script
#1
This is an utterly simple script to keep your server going. This can be expanded to do so much more, though that is for another day. I am posting this as mainly a starter script for some of you guys out there. (not many people ever use tldp.org, so ill bring it to you)

Create srcds_up.sh

Code:
#!/bin/sh

css="/home/myhomedir/css/"
process=`ps uxw | grep srcds_run | grep -v grep | awk '{print $11}'`

if [ -z "$process" ]; then

  echo "Couldn't find CSS running, restarting it."
  cd "$css"
  screen -d -m ./srcds_run -game cstrike -pingboost 3 -port 27015 +ip 127.0.0.1 +maxplayers 18 +map de_dust -autoupdate
  echo "Server Started"

fi

Now create a cronjob by typing "crontab -e"
Code:
*/1 * * * * /home/myhomedir/srcds_up.sh

That cronjob runs srcds_up.sh every minute. Your server should stay running unless it hangs and becomes a zombie process or you add a mod that causes it to crash over and over again.

*Hint if you want to add in some error checking to see if the server is up and accepting connections not just running, use qstat. -=]
Reply
#2
where should the cronjob be? is it a new file, in the srcds_up.sh or in the srcds.bat?
Reply
#3
This is a linux script....
...they, if you choose, end in .sh

.bat files are windows script files....
Reply
#4
So I would really love something like this for windows, but im really kinda a dumby and need step by step directions.
Reply
#5
jdrumstik Wrote:So I would really love something like this for windows, but im really kinda a dumby and need step by step directions.

You need to download a program to run srcds.exe as a service.
Reply
#6
(08-28-2009, 09:32 AM)jdrumstik Wrote:  So I would really love something like this for windows, but im really kinda a dumby and need step by step directions.

If you download my generic networking for the gamer guide there is included a method for running any windows .exe as a service (also allows auto-restarting etc.) I've used that method successfully with any/all of the dedi's I host for the various games I host.

here's the link to the thread containing my guide:
http://forums.srcds.com/viewtopic/5516

thanks,

the Monk
Reply
#7
Script is not complete: no fi and else.
Maybe you should make parameters variable:
parameters=`-game cstrike -pingboost 3 -port 27015 +ip 127.0.0.1 +maxplayers 18 +map de_dust -autoupdate` The users only have to change the variables on top op the script in stead of changing it where the code is.

Are you sure about the awk '{print $11} statement? When you change it to {print $2} you'll get the PID.
In the description there's no chmod +x srcds_up.sh
What if you're running multiple servers? (hint: serverport)
Reply
#8
Hi

it would be cool if you'd add a line for usage with multiple servers (fork)
this should be not this much of a problem, since you could filter for the forked server name.
Reply
#9
So this is a linux script correct?
Reply
#10
obviously it is.
Reply
#11
Please don't raise posts from the dead... This was initially posted in 2005... Open your own thread for support.
Looking for a game server? Visit fullfrag.com and pick one up as low as $2.50 / mo!
Reply
#12
Just thought I would help out a bit here Big Grin

My server didn't crash and die, it froze up which means the process were still running but the server didn't reply. So I asked and this guy helped me out with a script that don't check for the process but checks if the server replies to a net query/connection attempt.

Linux Bash and PHP script watchdog for SRCDS

hope this helps you out as much as it did me Wink
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)