Editing MG/Dedicated Server

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:
  
 
== Requirements ==
 
== Requirements ==
To host your own headless server, you will need a dedicated or virtual private server which roughly meets the minimum requirements the [https://github.com/MegaGlest/megaglest-source/blob/develop/docs/README.txt MegaGlest README] lists. You should actually be okay with 512 MB unallocated RAM (remaing free memory after the system has fully started up), though. A multi-core system is strongly recommended, and if these are virtual cores (VPS) then this system should not be running any other services. Graphics or audio cards are not needed. You do need a low latency Internet connection, though. Bandwith is not usually a problem (it might be if you operate under strict bandwidth restrictions and your MegaGlest server offers mods for download).
+
To host your own headless server, you will need a dedicated or virtual private server which roughly meets the minimum requirements the [http://sourceforge.net/apps/trac/megaglest/export/HEAD/trunk/docs/README.txt MegaGlest README] lists. You should actually be okay with 512 MB unallocated RAM (remaing free memory after the system has fully started up), though. A multi-core system is strongly recommended, and if these are virtual cores (VPS) then this system should not be running any other services. Graphics or audio cards are not needed. You do need a low latency Internet connection, though. Bandwith is not usually a problem (it might be if you operate under strict bandwidth restrictions and your MegaGlest server offers mods for download).
  
 
==Hosting==
 
==Hosting==
Line 8: Line 8:
 
Unless you own / rent a dedicated server where you can setup a VPS for MegaGlest, the cheapest way to host is probably to go with a Virtual Private Server (VPS). There are unbelievably many VPS providers out there and we have little to no experience with them so we can't really make a recommendation at this point. Prices range from less than US $10 per month to amounts which would be better spent on a dedicated server. Please check websites such as [http://www.lowendbox.com/ lowendbox.com], [http://www.webhostingtalk.com webhostingtalk.com] and [http://webhostlist.de webhostlist.de] which compare and discuss various offers.
 
Unless you own / rent a dedicated server where you can setup a VPS for MegaGlest, the cheapest way to host is probably to go with a Virtual Private Server (VPS). There are unbelievably many VPS providers out there and we have little to no experience with them so we can't really make a recommendation at this point. Prices range from less than US $10 per month to amounts which would be better spent on a dedicated server. Please check websites such as [http://www.lowendbox.com/ lowendbox.com], [http://www.webhostingtalk.com webhostingtalk.com] and [http://webhostlist.de webhostlist.de] which compare and discuss various offers.
  
There are also few 'free' VPS offers. All we can say there is that Amazons [http://aws.amazon.com/free/ free-for-one-year VPS] and [http://www.host1free.com/free-vps/ Host1Free's VPS] do not provide sufficient resources to run a dedicated gameserver while ''some'' of the offers by [http://freevps.us/page-requirements.html FreeVPS.us] may work based on the resources they list. But we haven't actually tried this, since, of course, this offer is not entirely free but you need to dance the hula-hula. Generally, there are only few ''free'' offers on the Internet now, and those are usually by idealistic computer enthusiasts, almost never by companies - those always come with strings attached (which is completely understandable from their profit driven perspective). There are also donation based offers, or organisations operating without the target of/need to make profits (community service / hosting / colocation providers), which can be a good choice.
+
There are also few 'free' VPS offers. All we can say there is that Amazons [http://aws.amazon.com/free/ free-for-one-year VPS] and [http://www.host1free.com/free-vps/ Host1Free's VPS] do not provide sufficient resources to run a dedicated gameserver while ''some'' of the offers by [http://freevps.us/page-requirements.html FreeVPS.us] may work based on the resources they list. But we haven't actually tried this, since, of course, this offer is not entirely free but you need to dance the hula-hula. Generally, there are only few ''free'' offers on the Internet now, and those are usually by idealistic computer enthusiasts, almost never by companies - those always come with strings attached (which is completely understandable from their profit driven perspective). There are also donation based offers, or organisations operating without the target of/need to generating profits (community service / hosting / colocation providers), which can be a good choice.
  
 
==Operating system==
 
==Operating system==
Since we have to decide for one operating system, we go the easy (and good) way and use Debian GNU/Linux "Stable". These steps ''may'' also work on later Debian versions as well as on Ubuntu servers.
+
Since we have to decide for one operating system, we go the easy (and good) way and use Debian GNU/Linux 6.0 (Squeeze). These steps ''may'' also work on later Debian versions as well as on Ubuntu servers.
  
 
Install a minimal Debian GNU/Linux server. This can be done with a Debian ''Netinstall'' CD image as well as by many other ways. The details are considered out of the scope of this manual - see the Debian website and installation manual.
 
Install a minimal Debian GNU/Linux server. This can be done with a Debian ''Netinstall'' CD image as well as by many other ways. The details are considered out of the scope of this manual - see the Debian website and installation manual.
Line 23: Line 23:
 
==MegaGlest installation==
 
==MegaGlest installation==
  
The next steps are specific to the installation and configuration of MegaGlest on your dedicated server. If you already have a working multi-use(r) Debian server, this is the point to start following this tutorial.
+
The next steps are specific to the installation and configuration of MegaGlest on your dedicated server. If you already have a working multi-use(r) Debian 6.0 server, this is the point to start following this tutorial.
  
 
Still working as ''root'', create a new restricted user ''megaglest'':
 
Still working as ''root'', create a new restricted user ''megaglest'':
  
  adduser megaglest --disabled-password --gecos ""
+
  adduser megaglest --disabled-password --gecos
  
Also as ''root'', install dependencies for MegaGlest (this list for sure may be outdated, but missing libs should be quite easy to find out e.g. thanks to error messages from start_megaglest script):
+
Also as ''root'', install dependencies for MegaGlest:
  
  apt-get install xz-utils p7zip-full libsdl2-2.0-0 libglu1 libsm6 libopenal1 libvorbisfile3 libglew1.5 libfontconfig1 libldap-2.4-2 libidn11 binutils
+
  apt-get install xz-utils p7zip-full libsdl1.2debian libglu1 libsm6 libopenal1 libvorbisfile3 libglew1.5 libfontconfig1 libldap-2.4-2 libidn11 binutils
 
 
On older Debian derivates you would need to use package ''libsdl2'' instead of ''libsdl2-2.0-0''.
 
  
 
Now switch to the ''megaglest'' user, this is the last time you need to work as ''root'':
 
Now switch to the ''megaglest'' user, this is the last time you need to work as ''root'':
Line 39: Line 37:
 
  su -l megaglest
 
  su -l megaglest
  
Download [https://github.com/MegaGlest/megaglest-source/releases/ binary] and [https://github.com/MegaGlest/megaglest-data/releases/ data] archives for the latest stable MegaGlest release. If your server runs a 64 bit operating system (the ''arch'' command says ''x86_64'') then go for the 64 bit Linux binary and data archives, otherwise use the 32 bit ones. You can download these using ''wget'', here's an example on how to do it with MegaGlest 3.13.0 for a 64 bit server:
+
[http://megaglest.org/download.html Download] binary and data archives for the latest stable MegaGlest release. On the download page, scroll down to the table and copy the two URLs there. If your server runs a 64 bit operating system (the ''arch'' command should say ''x86_64'' then) then go for the 64 bit Linux binary and data archives, otherwise use the 32 bit ones. You can download these using ''wget'', here's an example on how to do it with MegaGlest 3.6.0.3 for a 64 bit server:
  
  wget https://github.com/MegaGlest/megaglest-source/releases/download/3.13.0/megaglest-binary-linux-x86_64-3.13.0.tar.xz
+
  wget [http://sourceforge.net/projects/megaglest/files/megaglest_3.6.0.3/megaglest3.6.0.3_i386_64_linux_bin.tar.bz2 http://sourceforge.net/projects/megaglest/files/megaglest_3.6.0.3/megaglest3.6.0.3_i386_64_linux_bin.tar.xz]
  wget https://github.com/MegaGlest/megaglest-data/releases/download/3.13.0/megaglest-standalone-data-3.13.0.tar.xz
+
  wget http://sourceforge.net/projects/megaglest/files/megaglest_3.6.0.3/megaglest-data-3.6.0.3.tar.xz
  
Create a directory, add a convenient symbolic link, unpack both archives and delete some files you do not need on a headless server (only!) as follows:
+
Unpack, add a convenient symlink, then (optionally) clean up:
  
  mkdir megaglest-3.13.0
+
  tar -xJf ./megaglest-data-3.6.0.3.tar.xz
  ln -s megaglest-3.13.0 megaglest-server
+
  ln -s megaglest-3.6.0.3 megaglest
  cd megaglest-server
+
  cd ./megaglest-3.6.0.3
# Expanding game data can take a while, it is well compressed
+
  tar -xJf ../megaglest3.6.0.3_i386_64_linux_bin.tar.xz
tar -xJf ../megaglest-standalone-data-3.13.0.tar.xz
+
  rm start_megaglest_g3dviewer start_megaglest_mapeditor megaglest_editor megaglest_g3dviewer
  tar -xJf ../megaglest-binary-linux-x86_64-3.13.0.tar.xz
+
  mkdir -p ~/.megaglest
  rm megaglest_g3dviewer start_megaglest_g3dviewer megaglest_editor start_megaglest_mapeditor *.desktop *.ico
 
 
 
If everything went well, it should look roughly like this:
 
 
 
  megaglest@gameserver:~/megaglest-server$ ls -lF
 
total 120904
 
drwxr-xr-x  2 megaglest megaglest      4096 Mar  8 21:41 blender/
 
-rw-r--r--  1 megaglest megaglest        29 Mar  8 21:41 build-time.log
 
drwxr-xr-x  4 megaglest megaglest      4096 Mar  8 21:43 data/
 
drwxr-xr-x  3 megaglest megaglest      4096 Mar  8 21:43 docs/
 
-rw-r--r--  1 megaglest megaglest      3666 Mar  8 21:41 glest.ini
 
-rw-r--r--  1 megaglest megaglest      1135 Mar  8 21:41 glestkeys.ini
 
-rw-r--r--  1 megaglest megaglest     5333 Mar  8 21:41 ldd-megaglest.log
 
drwxr-xr-x  3 megaglest megaglest      4096 Mar 12 14:31 lib/
 
drwxr-xr-x  2 megaglest megaglest      4096 Mar  8 21:43 maps/
 
-rwxr-xr-x  1 megaglest megaglest 123665044 Mar  8 21:41 megaglest*
 
-rw-r--r--  1 megaglest megaglest      4150 Mar  8 21:41 megaglest.bmp
 
-rwxr-xr-x  1 megaglest megaglest      1775 Mar  8 21:41 megaglest-mini-update.sh*
 
-rw-r--r--  1 megaglest megaglest      4581 Mar  8 21:41 megaglest.png
 
-rw-r--r--  1 megaglest megaglest    17785 Mar  8 21:41 megaglest.xpm
 
drwxr-xr-x 25 megaglest megaglest      4096 Mar  8 21:43 scenarios/
 
-rw-r--r--  1 megaglest megaglest      145 Mar  8 21:41 servers.ini
 
-rwxr-xr-x  1 megaglest megaglest    20252 Mar  8 21:41 start_megaglest*
 
-rwxr-xr-x  1 megaglest megaglest    15548 Mar  8 21:41 start_megaglest_gameserver*
 
drwxr-xr-x  4 megaglest megaglest      4096 Mar  8 21:43 techs/
 
drwxr-xr-x 21 megaglest megaglest      4096 Mar  8 21:43 tilesets/
 
drwxr-xr-x  5 megaglest megaglest      4096 Mar  8 21:43 tutorials/
 
  
 
Do a test run:
 
Do a test run:
  
  megaglest@gameserver:~/megaglest-server$ ./start_megaglest --version
+
  megaglest@gameserver:~/megaglest-3.6.0.3$ ./start_megaglest --version
  megaglest v3.13.0
+
gamedir [/home/megaglest/megaglest-3.6.0.3]
  Compiled using: GNUC: 40804 [64bit] platform: Linux-X64 endianness: little
+
Looking for LDCONFIG []...
  GIT: [Rev: 5607.967257e] - using STREFLOP [SSE] - [no-denormals]
+
LDCONFIG environment variable is not set...
 +
Found LDCONFIG using which [/sbin/ldconfig]...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libopenal.so.1] was found in [/usr/lib/libopenal.so.1]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libdirectfb-1.2.so.0] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libfusion-1.2.so.0] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libdirect-1.2.so.0] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libjpeg.so.62] was found in [/usr/lib/x86_64-linux-gnu/libjpeg.so.62]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libpng15.so.15] is missing, attempting to find and link to a newer version if available...
 +
new library link [/lib/x86_64-linux-gnu/libpng12.so.0] pointed to from [/home/megaglest/megaglest-3.6.0.3/lib/libpng15.so.15]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libcurl.so.4] was found in [/usr/lib/libcurl.so.4]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libxerces-c-3.1.so] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libicudata.so.40] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libicuuc.so.40] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libGLEW.so.1.5] was found in [/usr/lib/libGLEW.so.1.5]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libGLEW.so.1.5] was found in [/usr/lib/libGLEW.so.1.5]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libogg.so.0] was found in [/usr/lib/libogg.so.0]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libvorbis.so.0] was found in [/usr/lib/libvorbis.so.0]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libvorbisfile.so.3] was found in [/usr/lib/libvorbisfile.so.3]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libfontconfig.so.1] was found in [/usr/lib/x86_64-linux-gnu/libfontconfig.so.1]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libfreetype.so.6] was found in [/usr/lib/x86_64-linux-gnu/libfreetype.so.6]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libgnutls.so.26] was found in [/usr/lib/x86_64-linux-gnu/libgnutls.so.26]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libldap_r-2.4.so.2] was found in [/usr/lib/libldap_r-2.4.so.2]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libresolv.so.2] was found in [/lib/x86_64-linux-gnu/libresolv.so.2]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/liblua5.1.so.0] was found in [/usr/lib/liblua5.1.so.0]
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libftgl.so.2] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libircclient.so.1] is missing, attempting to find and link to a newer version if available...
 +
default library [/home/megaglest/megaglest-3.6.0.3/lib/libdl.so.2] was found in [/lib/x86_64-linux-gnu/libdl.so.2]
 +
  megaglest v3.6.0.3
 +
  Compiled using: GNUC: 40401 [64bit] on: Jan 24 2012 13:33:42
 +
  SVN: [Rev: 3080] - using STREFLOP
 +
megaglest@gameserver:~/megaglest$
  
If MegaGlest fails to start here, please check the [http://faq.megaglest.org FAQ] .
+
These ''default library'' messages (which are sent to to the error output stream) are completely normal and can be ignored unless errors about missing libraries are reported. The only line returned to standard output are those three last lines which provide the version info. If MegaGlest fails to start here, please check the [http://faq.megaglest.org FAQ] .
  
 
==MegaGlest configuration==
 
==MegaGlest configuration==
Line 100: Line 101:
 
You are now ready to go. However, for advanced configuration, many more options which may matter for a game server are available. Here is an optional example for a more complex <code>~/.megaglest/glestuser.ini</code> file:
 
You are now ready to go. However, for advanced configuration, many more options which may matter for a game server are available. Here is an optional example for a more complex <code>~/.megaglest/glestuser.ini</code> file:
 
  ### For more information on these options, please consult
 
  ### For more information on these options, please consult
  ### [[MG/INI|https://wiki.megaglest.org/INI]]
+
  ### [[MG/INI|http://wiki.megaglest.org/INI]]
 
   
 
   
 
  ### Network settings
 
  ### Network settings
 
  NetPlayerName=Edit_glestuser.ini
 
  NetPlayerName=Edit_glestuser.ini
  #PortList=61357,61367,61377,61387,61397
+
  #ServerPort=61357
  #PortServer=61357
+
  #MasterServerExternalPort=61357
 
  #FTPServerPort=61358
 
  #FTPServerPort=61358
 
  #EnableFTPServer=1
 
  #EnableFTPServer=1
Line 111: Line 112:
 
  #EnableFTPServerInternetTilesetXfer=1
 
  #EnableFTPServerInternetTilesetXfer=1
 
  #EnableFTPXfer=1
 
  #EnableFTPXfer=1
  #Masterserver=[[MG/INI|https://master.megaglest.org/]]
+
  #Masterserver=[[MG/INI|http://master.megaglest.org/]]
 
   
 
   
 
  ### Logging
 
  ### Logging
Line 133: Line 134:
 
  #FileArchiveExtension=.7z 
 
  #FileArchiveExtension=.7z 
  
<span style="font-size:13px;">These and all other glestuser.ini options are</span><span style="font-size:13px;"> </span>[[MG/INI|documented on this wiki]]<span style="font-size:13px;">. Note that they may change between releases, so when you upgrade your server to the latest version, be sure to read the [http://changelog.megaglest.org changelog] and review the INI document.</span>
+
<span style="font-size:13px;">These and all other glestuser.ini options are</span><span style="font-size:13px;"> </span>[[MG/INI|documented on this wiki]]<span style="font-size:13px;">. Note that they may change between releases, so when you upgrade your server to the latest version, be sure to read the changelog and review the INI document.</span>
  
 
==Firewall configuration==
 
==Firewall configuration==
Line 154: Line 155:
 
==Testing==
 
==Testing==
  
You should now be able to start a server and it should automatically publish to the [[MG/Master_Server|master server]] (this can take up to two minutes).
+
You should now be able to start a server and it should automatically publish to the master server (this can take up to two minutes).
  
 
To run a headless server and register with the masterserver run:
 
To run a headless server and register with the masterserver run:
  
./start_megaglest --headless-server-mode=exit
+
'''./start_megaglest --headless-server-mode=exit'''
  
(run ''megaglest --help'' to see all available options)
+
(for full options run megaglest --help to see all parameters)
  
 
Currently available game servers are listed at [http://play.mg Play.MG] , so your server should show up there with its IP address and the server/player name you have set. If publishing to the master server does not seem to work try running the server with ''--verbose'' option as discussed in the [http://faq.megaglest.org FAQ]. 
 
Currently available game servers are listed at [http://play.mg Play.MG] , so your server should show up there with its IP address and the server/player name you have set. If publishing to the master server does not seem to work try running the server with ''--verbose'' option as discussed in the [http://faq.megaglest.org FAQ]. 
Line 174: Line 175:
  
 
==Game server automation==
 
==Game server automation==
If you want to run the game server regularly, you can introduce some level of automation. You may want to make it start up automatically on boot. And, while we are not aware of any, to rule out side effects which may drain on system resources, you should have the game quit and restart after every played game. After all, restarting the game is very quick and does not hurt.
 
===Why not initd?===
 
The common Unix way of managing daemons is sysv-initd and its various derived approaches such as upstart and systemd, which are often not compatible. So if you wanted to write an initd-like script for MegaGlest, you would have to do it for every initd-like mechanisms which is in use these days.
 
  
You should also keep in mind that initd's concept is that you start a daemon process (storing its single process ID as a reference) and keep it running until you manually stop it through initd (effectively killing the process by its stored process ID). That's quite different to a daemon restarting itself regularly, getting a new process ID assigned each time it restarts, as should be the case for a MegaGlest game server. Howwever, this could still be done with an intermediary control / process monitoring layer, basically like a master process spawnings and killing its child processes, representing itself to initd-like daemon as a sincle process with a static process ID,
+
If you want to run the game server regularly, you can introduce some level of automation. You may want to make it start up automatically on boot. And you most likely want to have it quit and restart the game process after every played game to rule out side effects which may drain on system resources - remember, the headless server is still a pretty young feature, and restarting the game is very quick and does not hurt. Here's a crontab and a management script to do both of the above:
  
Finally, managing an initd-controlled process requires root access (which you may not have at any given time if you are not the sole user of thie server).
+
wget http://dl.megaglest.org/megaglest-gameserver.tar.gz
 +
tar xzf megaglest-gameserver.tar.gz
 +
chmod +x start_megaglest_gameserver.sh
 +
# Careful: only do this when there is not already a crontab for your user ('crontab -l' to check).
 +
# In case there already is one then just add the contents of the 'cron' file to your crontab,
 +
# by running crontab -e.
 +
crontab cron
 +
rm megaglest-gameserver.tar.gz cron
  
As a result of these thoughts, no initd-like scripts are provided for MegaGlest at this time. We would appreciate contributions under compatible license terms if you are willing to maintain it, though.
+
After the next reboot, the gameserver should start up automatically.
 
 
For now, there are other options, as discussed below.
 
===Using Crond===
 
 
 
The easiest and most simple way to manage your headless server is to use the wrapper script  start_megaglest_gameserver which ships with MegaGlest. This script starts MegaGlest as a headless server and makes it quit after each played game.
 
 
 
The only thing missing then is a machanism to start this script automatically during boot of the server. This can be achieved by a crontab. To install it, working as the user which runs the gamserver, use
 
 
 
crontab -e
 
to spawn the crontab editor, then add this:
 
@reboot $HOME/megaglest-server/start_megaglest_gameserver >/dev/null
 
You may also want to set the MAIL variable on top of this file to ensure you receive email notifications in case of an error.
 
 
 
With this script in place, server logs are created at <tt>~/.megaglest/server.log</tt> and ''can'' grow massively. You may want to rotate and/or compress them (or not create them in the first place).
 
  
After the next reboot, the gameserver should start up automatically.
+
With this script, server logs are created at ~/.megaglest/server.log and can grow big. You may want to rotate and/or compress them (or not create them in the first place).
===Using restartd===
 
[https://github.com/ajraymond/restartd restartd] is a simple job control system which does not interfere with your distributions' initd-like mechanism, but adds to it. So far it is mostly used on (and packaged for) Debian GNU/Linux but it is by no means limited to it.
 
[[Category:MG]]
 
  
 
==Status reporting==
 
==Status reporting==
Line 239: Line 227:
 
*[[Multiplayer]]
 
*[[Multiplayer]]
 
[[Category:MG]]
 
[[Category:MG]]
[[Category:Multiplayer]]
 
[[Category:HOW-TOs]]
 

Please note that all contributions to MegaGlest are considered to be released under the Creative Commons Attribution Share Alike (see MegaGlest:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)