SRCDS Steam group


start server on reboot -- linux only
#1
This tutorial is for linux servers as I do not run win32 servers.

To start off this tutorial you'll need to add
Code:
-pidfile srcds.pid
to your srcds_run command. this will add the process id into a file. At the moment of writing this, -pidfile did not work correctly so until valve fixes this, you can use this. http://www.machgaming.net/srcds_run.patch.gz which is a patch for srcds_run to use -pidfile
on to the next part, you'll need a crontab, i happen to use vixie-cron. most distros probably come with cron however. If not you can try this, for fedora and debian you can probably..
Quote:Fedora: yum vixie-cron
Debian apt-get vixie-cron
FreeBSD: use ports to install vixie-cron(if you don't know how to do this, you shouldn't be using FreeBSD Smile)
Gentoo: emerge vixie-cron

When crontab is installed simply run "crontab -e" to open the cron editor and add:
Code:
*/5 * * * * /home/yoursrcdspath/srcdchk.sh


This will make cron run srcdchk.sh every 5 minutes. be sure you change "yoursrcdspath" to the path of your srcds_run. You can change the /5 to /1 if you wish. Credit: SirTiger from his full throttle tutorial.

next we'll need the srcdchk.sh
Code:
#!/bin/sh
dir="./"

# change this to how you normally run your srcds:
srcdexe="srcds_run -game cstrike -ip 64.182.75.26 -port 27015 +map de_dust +maxplayers 20 -pidfile srcds.pid"

# I wouldn't touch this if I were you.
srcdname="srcds.pid"

########## you probably don't need to change anything below here ##########

cd $dir
if test -r $srcdname; then
  # there is a pid file -- is it current?
  srcdpid=`cat $srcdname`
  if `kill -CHLD $srcdpid >/dev/null 2>&1`; then
    # it's still going
    # back out quietly
    exit 0
  fi
  echo "Source Dedicated Server Crontab notice:"
  echo ""
  echo "Stale $srcdname file (erasing it)"
  rm -f $srcdname
fi
echo ""
echo "Couldn't find the srcds running.  Reloading it..."
echo ""
./$srcdexe
don't forget to
Code:
chmod +x srcdchk.sh
This will also help if the server stops for some reason and does not auto start. There is another way of doing this, which is adding srcdchk.sh to rc scripts. for gentoo its in
Quote:/etc/init.d/start.local
I'm not sure about fedora or debian , its probably something like
Quote:/etc/rc.d/start.local
if someone would please clearify this i'll edit the tutorial to fit it.

Please note that your user that runs this script in cron tab, must be in the group cron.
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
Reply
#2
Debian users should use a symlinked script (using update-rc.d preferably) found in /etc/rcX.d (where X is the runlevel you're after, 2 upwards is multiuser). You can (if you're confident) place your script in /etc/init.d/ and then add a symlink to the appropriate rc directory in the following format:
SXXname -> ../init.d/scriptname*
First letter of the ln name should be S or H (start or halt), the XX is a number between 01 and 99 to indicate the order this program should be run, and the name is chosen by you (should reflect the name of the script/program to run).

Alternatively, if you're of a nervous disposition I would suggest the following modifications if you're running Debian:

Place the srcdchk.sh into /etc/init.d/ and then use the following command (from any directory).

Code:
update-rc.d srcdchk.sh defaults 99

This will add your script to all the important (non halt, non reboot) runlevels and give it a start priority of 99 (basically it will be the last thing to startup - change this if you like).

Hope this helps,

James
Reply
#3
For Fedora and other Red Hat flavors, services are started by SysV initscripts in /etc/rc.d/*. There's an init.d subdirectory where the actual script is stored. There are also per-runlevel subdirectories rc0.d through rc6.d that hold symlinks to the actual scripts. These symlinks are created and managed by the chkconfig command.

For more information, look in /usr/share/doc/initscripts-*. (The directory name will end in the version of the initscripts package you have installed.)

I haven't yet written one of these for srcds but I've written them for Tribes 2, Tribes Vengeance, and BF1942. You can see my TV scripts here:

http://matureasskickers.net/ftp/TribesVengeance/tvserver-scripts.tar.gz
Reply
#4
Hey, I've been trying to use the crontab method of starting the server. The problem I'm running into is that the script won't execute via crontab. After I fixed the typo on one of the variable names, it works fine when I run it directly, but when I put it into cron for the user who should be running the server nothing happens. Does anyone have any ideas?
Reply
#5
Try adding that user to the cron group
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
Reply
#6
cryotek Wrote:Try adding that user to the cron group

Yeah, I did that, and cron is running, but the server still isn't being launched.
Reply
#7
is there a dead.letter in the users homedir?
[Image: userbar_wow.jpg]
starting 9/24/2006 if your problem has been solved please edit your first post and add [solved] to the begining of the title. Thanks.
Reply
#8
I've put the init-script for SuSE and the UnitedLinux-flavors on my webserver. It uses a configfile in /etc/sysconfig where all the settings can be made (such as map, maxplayers etc).
When you use SuSE you can also use Yast to modify the settings.
In the archive is a readme how to use it.

Download it
Note for our MickeySoft users:
A reboot a day, keeps Dr.Watson away Big Grin
Reply
#9
Doh! I just noticed my response never got posted. How annoying. I got it working. It seems EL3's cron for some reason doesn't support the */5 style, so I replaced it with 0,5,10,15... and it works fine.
Reply
#10
ok problems.. i have started a new crontab and got the pidfile, and everything but the server will not work. i manually got into shell and used the suplied .sh file and manually ran the program and it worked.

do i need to have a shell running in order for crontab to work? if not why isnt it running.. i tried it under the user and also root with no success.
Reply
#11
What distro? Is some kind of cron service installed and running?
Reply
#12
yea i edited the cron and everything also when that didnt work i have plesk reloaded on my machine and added a new crontab in there as well. tried it as root, didnt work.

fedora core 2 is my distro..

thanks for the responce.
Reply
#13
Does anyone have a mirror for the pid patch? It's 404ing.
Reply
#14
ya i need that patch too...
Reply
#15
nmd, they fixed it no need for patch
http://multiplayergamers.com/modules.php?op=modload&name=News&file=article&sid=278&mode=thread&order=0&thold=0
if you want da patch anyway there is a link
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)