Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
03-23-2011, 06:39 AM
(This post was last modified: 03-23-2011, 06:40 AM by Dragineez.)
Seems a silly question, but days of research and I can't find any info on how to stop the server. Everything I've found says "stop and restart your server" but never explains how to do that.
Running on Ubuntu 10.10 x86, 1.8Ghz P4 (Whoo Hoo!)
Start up script:
./scrds_run -autoupdate -game left4dead -ip 0.0.0.0 -port 27015 +map c1m1_themapname.bsp &
So it's not controlled by init.d and I can't start/stop it from there. Now that they've made it recover from crashes, if I kill the process it just restarts.
How do I tell it to stop? (Hides head in shame....
Posts: 779
Threads: 5
Joined: Apr 2008
Reputation:
9
Maybe you want to use the script on the second page:
http://forums.srcds.com/viewtopic/16356
Warning Level: 0%
Posts: 5
Threads: 2
Joined: Oct 2010
Reputation:
0
I do "quit" in the server to restart the server.
but you can also kill the screen and run server.sh
Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
03-23-2011, 09:32 AM
(This post was last modified: 03-23-2011, 09:39 AM by Dragineez.)
(03-23-2011, 07:32 AM)Arjen Wrote: Maybe you want to use the script on the second page:
http://forums.srcds.com/viewtopic/16356
Ha! Ha! I was reading that thread but when he got to the part when he didn't know how to change directory, list the files in the directory, or know what directory he was in... I figured it wasn't going to help me very much. I like the script, but I don't see how that helps me stop the server. I'll go back and look at it more closely.
Thanx for the reply.
+-+-+-+
It looks like it's using kill, and I've been doing that. The new srcds_run auto-restarts after a crash (which behavior I most heartily approve of), so killing it doesn't keep it dead. Also, if the script auto-restarts the server that is going ot auto-restart itself I can see it starting multiple instances of the server every time it crashes of is killed.
Posts: 7
Threads: 1
Joined: Mar 2011
Reputation:
0
In the console just hit ctrl+c to stop the server. Optionally I use screen to hide the console in the background so that when I ssh into my box I don't have to keep the window open. Here is the script I use:
Code:
#!/bin/sh
echo "Starting CS:S Server..."
sleep 1
screen -A -m -d -S css-server srcds/orangebox/srcds_run -console -game cstrike +map de_dust2 -maxplayers 11 +ip 0.0.0.0 -autoupdate -pidfile srcds.pid
The script and srcds dir are in my home directory. So I just ssh into the box and type ./cstrike.sh which starts my server.
To view the console I type: screen -x css-server
To hide the window again hit ctrl+a then d
Posts: 779
Threads: 5
Joined: Apr 2008
Reputation:
9
(03-23-2011, 09:32 AM)Dragineez Wrote: (03-23-2011, 07:32 AM)Arjen Wrote: Maybe you want to use the script on the second page:
http://forums.srcds.com/viewtopic/16356
Ha! Ha! I was reading that thread but when he got to the part when he didn't know how to change directory, list the files in the directory, or know what directory he was in... I figured it wasn't going to help me very much. I like the script, but I don't see how that helps me stop the server. I'll go back and look at it more closely.
Thanx for the reply.
+-+-+-+
It looks like it's using kill, and I've been doing that. The new srcds_run auto-restarts after a crash (which behavior I most heartily approve of), so killing it doesn't keep it dead. Also, if the script auto-restarts the server that is going ot auto-restart itself I can see it starting multiple instances of the server every time it crashes of is killed.
Add the script to the crontab ...
Warning Level: 0%
Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
I don't see how adding it to the crontab helps me. Isn't the crontab just to schedule timed execution of a program? What am I missing? Perhaps you meant init.d. I could see adding the server startup script to init'd, but I'm not sure if it would be treated as a start-able/stop-able service. Wouldn't it just do a crash recovery restart every time I tried to stop it?
Sorry to be obtuse, but I find it odd there doesn't seem to be an explicit quit/stop/terminate switch for srcds_run.
Posts: 2,031
Threads: 27
Joined: Nov 2008
Reputation:
17
(03-26-2011, 01:08 AM)Dragineez Wrote: Sorry to be obtuse, but I find it odd there doesn't seem to be an explicit quit/stop/terminate switch for srcds_run.
of course there is. you write yourself how you start it, and stopping is also quite easy and written here in this thread multiple times. probably we just don't understand really, what you want to do.
how do you expect to start or stop your server? I always recommend running the server inside a " screen". then you can disconnect from the screen session (while keeping the server running) and reconnect later and have full access to the console. stopping is quite easy then, just hit Ctrl+C.
Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
I've tried both exiting the terminal session where the server was started and using the kill command. What I'm seeing happen is that the server is doing exactly what it was designed to do. Recover from a crash and automatically restart itself. I can see the process restart itself under a new pid. Right now I'm rebooting the PC to make sure the server stays dead so I can make changes. One should never have to do that in Linux. I'm sure I don't if I could figure out how to stop it. I know about the -noautorestart switch and I'll use it if I have to, but I'd like to be able to explicitly stop the server without it automatically respawning the process whilst retaining the crash recovery ability.
Posts: 2,031
Threads: 27
Joined: Nov 2008
Reputation:
17
03-29-2011, 06:00 PM
(This post was last modified: 03-29-2011, 06:02 PM by BehaartesEtwas.)
the switch is -norestart, and also don't use -autoupdate.
you can also kill srcds_run instead of srcds_linux. if you end the screen session where you started srcds_run inside, it will terminate the script too, so no autorestarting happens.
Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
Thanx, I'll give those a shot. One thing I've been doing that may be unnecessarily complicating things is starting multiple server processes from the same terminal session. If I kill the session I kill processes I want to keep alive. Your (and Arjen's) suggestion of using screen has been very helpful too.
Posts: 2,031
Threads: 27
Joined: Nov 2008
Reputation:
17
that's why most people use screen. you can start multiple servers from the same session, even close the session, and have (or re-gain) nevertheless full control of the server at any time. just put each server in its own screen session (and name the session correctly).
Posts: 6
Threads: 2
Joined: Apr 2011
Reputation:
0
When I tried to run screen ./server.sh it says it is starting the server then crashes.
when i run ./server.sh it runs fine but it won't let me quit the program. I try to kill the pid and it keeps reopening.
I am running this on a vps I am renting and I seem not to be able to login as anything but root even if I use the adduser and passwd create it. I'm not very well versed in Linux so maybe there are some fundamental things I am missing.
Posts: 41
Threads: 4
Joined: Mar 2011
Reputation:
0
If you want it to run under another user id, you have to give rights to that user so that the user id can run, see, open, and write files. BehaartesEtwas can correct be if I'm wrong, but try:
chmod -R 755 *
That will give all permissions to everyone to do anything except write to the file. You'll still have to be a sudoer or root to change the files.
Posts: 2,031
Threads: 27
Joined: Nov 2008
Reputation:
17
you really should avoid running game servers as root. normally useradd and passwd should be the right tools to create a new user which is working. try:
useradd -m someusername
passwd someusername
(the -m switch is important, else the home directory is not created.)
If you have installed the server as root, you will need to change the owner of all the files:
chown someusername:users -R /path/to/your/srcds/installation
I recommend against running something like chmod -R 755, as it will give permission to execute any file in the tree. better use:
chmod u+rwX,go+rX -R .
in the respective directory (please note the "." at the end which refers to the current directory). read the man page of chmod what this exactly does (type "man chmod")...
regarding your original problem: I don't exactly know what you are doing. if a script crashes inside screen but not outside, something is really wrong. can you post both the exact error message of the crash and the whole script?
|