Running Multiple Servers on a single Linux computer

Introduction
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.

Server installation
Before doing anything, make sure to run apt-get update and apt-get upgrade

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/ cd /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) 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 cd /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 cd /home/0.2.8-armagetronad-sty+ct

Now you need this to run bootstrap.sh ./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

The tree
CD to /home/armagetronad/ cd /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:

cd /home/armagetronad/servers

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 ?

The scripts
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

nano /home/armagetronad/scripts/srv That creates a text file called srv in the scripts directory. Write the following lines in the file:

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: Save it and exit the same way as before.

BEFORE YOU RUN THE SCRIPT:

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  script.

Starting a single specific server
CD to /home/armagetronad/scripts/ cd /home/armagetronad/scripts/

Now if you want to start (or restart) a single server, just run ./start servername, for example ./start server1

GNU screen
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  on a terminal.

Listing the running servers
To see the existing windows, meaning here, the running servers, type. It will gives you a list of running windows.

Accessing and leaving a server console
To attach to a window, type. 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.

Log files
Everytime the  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  command inside the server console. It will close the server, and you will be able to see the message, and the server restarting.

Credits
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):

Install BZR Compiling Zthreads