Running Multiple Servers on a single Linux computer
Parts of this guide may be outdated.
If you'd like a more automated setup, see here: http://wiki.armagetronad.org/index.php?title=Setting_Up_Multiple_Armagetron_Servers_the_Easy_Way
If you like to experiment new settings, it might be that you come with a set of interesting servers. A shame if you cannot run them all at the same time. Here is how you can achieve this on a Linux server. Please refer to the lag and bandwidth chapters in the wiki before to run multiple servers. If you run too many, you might end with a very bad gameplay.
There is another webpage that looks similar to this but it has a few extra things: Running Multiple Servers In a Single Ubuntu Computer
This chapter will present you an easy way to run multiple servers on a single Linux computer, using GNU screen.
Before doing anything, make sure to run
This will insure your VPS is up to date.
You need to install the Armagetron Advanced Dedicated Server from your specific operating system's packages.
Linux source can be found at: https://launchpad.net/armagetronad/
For this tutorial we will use the 0.2.8-armagetronad-ct+sty branch CD into /home/
You should grab this stuff before working on the server:
sudo apt-get install bzr build-essential automake libboost-dev libxml2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev ftgl-dev libglew-dev bison pkg-config autoconf autotools-dev libprotobuf-dev protobuf-compiler
For fixing the login you need to do this (This fixes the login menu from not delayinh)
apt-get install libzthread-2.3-2 libzthread-dev
If the previous line does not work you may compile zthread yourself
wget http://voxel.dl.sourceforge.net/sourceforge/zthread/ZThread-2.3.2.tar.gz tar -xzf ZThread-2.3.2.tar.gz cd ZThread-2.3.2
CXXFLAGS=-fpermissive ./configure --prefix=/usr make && make install ldconfig
Then, cd back home
download the source files
bzr branch lp:~armagetronad-ct/armagetronad/0.2.8-armagetronad-sty+ct
once the source if finished downloading to the server CD to the branch
Now you need this to run bootstrap.sh
For CentOS users, you may need to install this for ./configure to work.
yum -y install libxml2-devel
Now configure the server. You can look up more options for configuration with ./configure --help. But we will configure the server to be, this way
./configure --disable-glout --enable-authentication --prefix=/home/armagetronad --exec_prefix=/home/armagetronad --with-zthread
once that is configured execute the following command.
sudo make install
Now your server has been installed in /home/armagetronad/bin
now continues through the rest of the steps
Preparing the servers
CD to /home/armagetronad/
Create the following sub directories:
mkdir servers 'This folder will be used to store server configurations mkdir logs 'This one will be used to save the server logs mkdir scripts 'And this one will be used to same the scripts we will see below
We have now to create our servers. To do so, go to the servers directory you have created earlier, and for each server, create a sub folder with a one-word name for the server, and one sub folder: var. For example:
To create a server called server1:
mkdir server1 mkdir server1/var
then copy your config files in the var sub folder.
You can then create a second server, and many more...
mkdir server2 mkdir server2/var
and so on...
The setting files
For each server, do not forget to create a "server_info.cfg" file (search the wiki about it), and to change the port number. Port can be from 4534 to 4540, meaning you can safely run up to 7 servers on the same computer, depending obviously on the settings of each servers, and the bandwidth they need.
We assume that you know enough about Server Administration to understand the above explainations. This article is about Advanced Server Administration, isn't it ?
Now you have to create the scripts to launch and log all your servers. To allow managing each server separately, we will use GNU Screen. GNU screen is a terminal window manager. If it is not install on your server, you can get it with the usual installation tool (yum install screen, apt get screen, etc...). Again... advanced.... We assume you know how to install applications on linux and therefore, we assume GNU screen has been installed
You have to create two scripts. The first one will run a server and start logging the window in which the server has started. The second one will execute the first one for each folder in the /home/armagetronad/servers folder. It will create a window for each of them. Therefore, if you don't want a server to run, you will have to temporarily move the server folder out from the /home/armagetronad/servers directory.
Save the scripts in the /home/armagetronad/scripts directory. I use nano which is an easy text editor.
The server script
The first script will be called in this example: srv
That creates a text file called srv in the scripts directory. Write the following lines in the file:
#!/bin/bash loc="/home/armagetronad" mkdir $loc/logs/$1 screen -S $1 -X logtstamp on # print timestamps in log file screen -S $1 -X logfile $loc/logs/$1/$1_%m-%d-%Y-%c.log # create a logfile in the logs subf screen -S $1 -X log on # Turn on logging for the server window while true; do # start a loop to allow server restart if it crashes # runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is # in /home/armagetronad/bin directory. $loc/bin/armagetronad-dedicated --vardir $loc/servers/$1/var # Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel" sleep 5 done # end the loop
To save the file, press CTRL-X and Y to confirm. You have now a file called srv in /home/armagetronad/scripts
the global script
Create the second script. I called it start:
#!/bin/bash # If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in the /home/arma/servers directory # will be started if [ "$1" != "" ]; then screen -S $1 -X quit # Kill the window if it exists already, avoiding to run the same server twice screen -dmS $1 /home/armagetronad/scripts/srv $1 # start a GNU screen window with the specified server inside else for f in $(ls /home/armagetronad/scripts/servers/.) # start a loop running the following command for any existing folders in the # /home/armagetronad/servers folder do screen -S $f -X quit # Kill the window if it exists already, avoiding to run the same server twice screen -dmS $f /home/armagetronad/scripts/srv $f # start a GNU screen window with the server inside for each server folder done # ends the loop fi
Save it and exit the same way as before.
BEFORE YOU RUN THE SCRIPT:
chmod +x srv start
Starting all servers
To make your servers start at boot, edit the /etc/rc.local file and add the "start" script at the end of
If you want to manually start all servers, just run the
Starting a single specific server
CD to /home/armagetronad/scripts/
Now if you want to start (or restart) a single server, just run ./start servername, for example
GNU screen is a great tool. As explained above, it allow a multi-windowed environement on the simple terminal. And even better, the windows stay alive, evening when you disconnect from the server. You can find everything about GNU screen by typing
man screen on a terminal.
Listing the running servers
To see the existing windows, meaning here, the running servers, type
screen -ls. It will gives you a list of running windows.
Accessing and leaving a server console
To attach to a window, type
screen -r servername. You will be in the server console. You can then do all the command you would usually do there. Remote moderation, server adjustment, and so on.
To detach, but keep the server running, press CTRL-a d (control key + low case A, then low case D to detach). You can find all GNU screen key combinations by reading
Killing a server
To kill a server, attach to its window, and press CTRL-C. This will kill the script, and the window. Then press ESC to exit the dead window. An alternate way is to run
screen -S servername -X quit
This will kill and end the window and the server inside.
srv script is run, a new logfile will be created in the /opt/armagetronad/logs folder. Keep an eye on log sizes. You don't want to run out of disk space because of Armagetron Advanced, do you ?
Test the server autorestart
If you want to try if the server restarts when it crash, do not press CTRL-C into the window. CTRL-C kill the script, therefore it will not be able to restart. Instead, run the
quit command inside the server console. It will close the server, and you will be able to see the message, and the server restarting.
This article was originally written by Superkikim. These scripts and setup details are used to run the "FAST TRACK", "Most Wanted" and "Club Dutch" servers.
This article has been updated and optimized by Zurd. These optimized scripts based on Superkikim's original script are widely used by many Armagetron AD hosts today.
VPS packs to install
On Centos based systems (Fedora Core, Redhat):
yum groupinstall "Development Tools"
yum install libxml2-devel
su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm'
su -c 'yum install bzr'
CXXFLAGS=-fpermissive ./configure --prefix=/usr