Running a process as a service

Soldato
Joined
17 Jan 2005
Posts
8,770
Location
Liverpool
I'm trying to run a TF2 server off of my CentOS box.. I have got the server configured and running but I'd like it to start when my server reboots and run in the background.

I can get it running if I log in via Putty but as soon as I exit it closes it.. Is it possible to run it as a service as startup as a non root user?

Ta,
Andy
 
I've had a play with a script to try and get it loading but still nothing..

In my rc.local I have this..
sudo -H -u steam sh -c "cd /home/valve/orangebox && ./srcdslaunch" &

Which calls a file called srcdslaunch with the following in, located in the srcds folder
#!/bin/sh
echo "Starting SRCDS Server"
sleep 1
./srcds_run -console -game tf +ip **.**.**.** -port 27015 +maxplayers 24 +map ctf_2fort

Am I thinking in the right direction? Any other ideas? As far as I can tell that should work.. The srcdslaunch file works perfectly and starts the srcds process if I run that on its own..
 
Last edited:
Code:
rc-update add  /home/valve/orangebox/srcdslaunch default
Type that at the command line. It should do the job nicely :)

/edit- I misread your initial command line. You'll need to call a script that calls that full command line.
 
Last edited:
I tried creating a script in init.d and used chkconfig to add it to the startup list.

It now shows up in rc3.d as S99srcds and had the appropriate run levels under chkconfig. However it still doesn't boot! If i run the script manually it works perfectly..
 
What runlevel do you normally run under? That script will currently only execute if you boot up under runlevel 3. You could make a copy of the file into /etc/rc5.d and /etc/rc2.d or check your default runlevel in /etc/inittab
 
I chkconfiged it to run at 2, 3, 4 and 5 but it still wouldn't run.. Think I'm just going to give up and manually run the script each time I reboot the server.
 
Yeah, pretty much.
move your launcher script to the /etc/init.d (might be rc.d.. basically the directory with all the startup stuff) then just run
Code:
chkconfig <name of launcher file>

edit: just checked, move it to your /etc/rc3.d directory.
 
Yeh, I'd already done that.. Moved it to the init.d directory then ran chkconfig --add on the script. That added a sym link to the rc3.d directory with S99srcds but it still doesn't auto start! :confused:
 
Back
Top Bottom