Author Topic: nohup + running multiple Paintball servers + FreeBSD  (Read 2469 times)

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
nohup + running multiple Paintball servers + FreeBSD
« on: September 09, 2007, 12:45:38 AM »
I'm a FreeBSD server with several gigs of RAM. When I try to run two Paintball servers simultaneously with nohup and &, the first one usually (though not always) dies right as I start the second instance (which dies too). Strangely though, the two instances still appear under ps -a under root. I have to kill them with root in order to try again, because the ports are still taken up apparently.

Also, another oddity, attempting to redirect the output of the server doesn't work. The log stops being written too after a minute or too, and sometimes it's cut off (a line isn't complete). It used to work when I ran the server on Linux at the The Planet, but those days are gone.
« Last Edit: September 09, 2007, 01:36:13 AM by sk89q »

maxpower

  • VM-68
  • Posts: 170
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #1 on: September 09, 2007, 07:46:44 PM »
are they running on the same port?

KnacK

  • Global Moderator
  • Autococker
  • Posts: 3039
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #2 on: September 09, 2007, 07:54:26 PM »
1. Use screen
2. NEVER RUN ./paintball AS ROOT

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #3 on: September 09, 2007, 09:33:28 PM »
They're not running on the same port (hence why it works occasionally).

I don't have a screen. This is a server with colocation hosting in Los Angeles. I do have KVM over IP, but, that's not exactly too feasible. Either way, I don't think X is even installed.

It runs as a unprivileged user. I'm not sure Paintball even lets itself run as root.

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #4 on: September 10, 2007, 07:08:49 AM »
I don't have a screen. This is a server with colocation hosting in Los Angeles. I do have KVM over IP, but, that's not exactly too feasible. Either way, I don't think X is even installed.
screen is a program which acts as a tty emulator of sorts.  Basically it allows you to create multiple shell instances which can be detached(run in background) and re-attached whenever needed.  It comes installed on some servers by default, but it'll run on pretty much anything since it's one of the GNU tools.  The feature I like the most is that you can get back to the console of the server and execute commands and see the actual server output without having to tail log files.  It's great too that you can name each of your screens which makes it easier to get to the right one when you're running multiple servers.

Ex:
screen -r pub1
screen -r sk89q-private

My dedicated server setups have always followed this kind of implementation:
- A script which launches the server and automatically restarts it when it dies
Quote from: /home/pb2server/paintball2/pb2-public1.sh
#!/bin/sh
while true; do
  ./paintball2 +set deathmatch 1 +set dedicated 1 +set maxclients 12 +exec public1.cfg +map castle1
done
- A script which initializes the screen and starts the server
Quote from: /home/pb2server/paintball2/start_pb2-public1.sh
#!/bin/sh
cd /home/pb2server/paintball2
screen -A -m -d -S pb2-public1 ./pb2-public1.sh
- An init or cron script that takes care of launching the /home/pb2server/paintball2/start_pb2-public1.sh server as the pb2server user.

Now if you'd like to take a peek at your pub server's console you can perform a 'screen -r pb2-public1'.  Whenever you're done you can send it back to the background by detaching it by pressing Ctrl+A then Ctrl+D.  If you're only using one screen you can simply use 'screen -r'.  If you're using mutliple screens that will show you the names and pids of all the screens you have open.
« Last Edit: September 10, 2007, 11:31:06 AM by XtremeBain »

KnacK

  • Global Moderator
  • Autococker
  • Posts: 3039
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #5 on: September 10, 2007, 09:56:24 AM »
Bain,

Could you follow up with the content of your .sh file?

For those that are interested, XB uses a .sh file that is essentually a batch file with the complete command line variables to launch the server.

b00nlander

  • Autococker
  • Posts: 784
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #6 on: September 10, 2007, 10:48:24 AM »
nicely picked up from the w§w forums, bain :D
but I have to admit I use the same.

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #7 on: September 10, 2007, 11:30:48 AM »
nicely picked up from the w§w forums, bain :D
but I have to admit I use the same.

I actually run some pretty archaic stuff that Sad hooked me up with in 2001 that's been slightly modified over the years, but I knew that the warsow wiki had everything that I needed to give as an example.

KnacK

  • Global Moderator
  • Autococker
  • Posts: 3039
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #8 on: September 10, 2007, 11:33:05 AM »
Sorry,

I wasnt paying attention I guess - darn old timers disease.

Thanks Bain.

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #9 on: September 10, 2007, 12:11:27 PM »
I love you <3

If only I knew about this later. Just installed it and it works almost like a charm! CTRL-A and CTRL-D isn't do squat though. It did right after Paintball started, but stopped after a few lines went by, and I can't actually send commands to Paintball either. At least Paintball stays running.

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #10 on: September 10, 2007, 12:25:36 PM »
Are you using PuTTy or that IP KVM when trying that?

Edit: I'm just setting up one of these at work right now...  I wonder if it wouldn't be too much trouble to throw a server or two up ;)

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #11 on: September 10, 2007, 01:11:04 PM »
I'm SSHing through PuTTY.

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #12 on: September 10, 2007, 01:24:19 PM »
The script starts the server detached.
You need to use 'screen -r' to reattach the screen.  To detach the screen once it's attached you need to press CTRL-A and CTRL-D in sequence.
When the screen is attached you should be at the console of the server.  With the first script in place you can use 'quit' to kill the server and it will automatically restart.  If the server is hung and won't take a quit, a CTRL-C should sighup it and it'll restart, or you can always 'kill -9' it, either way it'll restart (as long as you don't kill the ./pb2-public1.sh process).  If you want to kill the server and screen all together, I just hold CTRL-C until it sighups out of the script's while loop (a couple seconds usually).

sk89q

  • Global Moderator
  • Autococker
  • Posts: 1049
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #13 on: September 10, 2007, 01:45:47 PM »
I wasn't using the script =/ I'll check it out though.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: nohup + running multiple Paintball servers + FreeBSD
« Reply #14 on: September 14, 2007, 01:20:09 PM »
I always hold down Ctrl and type "AD".  Not sure if that makes a difference.  I think it's technically supposed to be Ctrl-A, D.