Setting up a server

From Avorion Wiki
Jump to: navigation, search

[[1]] Usually a server is started up internally whenever you start up a public singleplayer game or go to the "Host Game" window in Multiplayer. People can connect to you then. However, if you want to run a dedicated server, things are a little more complicated. Avorion servers will shut down 28/07/18.

Requirements[edit | edit source]

There are several requirements that must be met before setting up a server. Especially if you want to play over the Internet.

  • Basic knowledge of the command line
  • Administrator rights are required for the setup
  • Make sure you're not behind a firewall. If you are, make sure that the server software is listed as exception. Providing a tutorial for that is not possible, it depends on your firewall.
  • Firewalls come in many different sizes and shapes. Your router has one. Your virus scanners may have one.
    • The UDP and TCP ports that will be used for the game must be forwarded to the machine that runs the game. These ports will need to be opened for the game to run by default:
      • 27000 - UDP & TCP
      • 27003 - UDP
      • 27020 - UDP
      • 27021 - UDP

If these preconditions are not met, the server might not work properly and people might not be able to connect.

Setting up the server (Windows)[edit | edit source]

[[2]]

Installing the Server FIles[edit | edit source]

  1. Download and extract SteamCMD. (https://developer.valvesoftware.com/wiki/SteamCMD)
  2. Create a directory for the server files, default being C:\steamcmd
  3. Locate steamcmd.exe and run it with the following arguments, depending on whether you want to run a default or beta server. Note that you need to replace <SERVER_PATH> with the path of the directory you just created.
    • Default: steamcmd.exe +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 validate +exit
    • Beta: steamcmd.exe +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 -beta beta validate +exit

Creating a Galaxy[edit | edit source]

This has to be done every time a new galaxy should be created:

  1. Locate and enter the directory of the Avorion server files within the steamCMD directory (C:\steamcmd\steamapps\common\AvorionServer).
  2. Copy server.bat and rename the copy to myserver.bat. The reason for that is that steam overwrites the server.bat every time you update the server.
  3. Open myserver.bat with an editor.
  4. Go ahead and change “avorion_admin” to your 64bit SteamID to make sure you are the admin of the server.
  5. Change the name of your galaxy by editing “avorion_galaxy” to the name of your galaxy.
  6. If you want to change the path where your galaxies are stored, you can add --datapath C:\PATHHERE to the list of arguments.
  7. Save the changes.
  8. Now run myserver.bat. This should start the server. Wait for it to finish initializing and then enter /save and /stop to stop the server. This initializes the galaxy config files.
  9. Open the server.ini of your galaxy. If you didn't change the path of your galaxies, it is stored at %appdata%/Avorion/galaxies/<YOURGALAXY>/
  10. An explanation of the available settings in this file is available here.
  11. Save the file.
  12. Congratulations! You finished setting up your galaxy.

Starting the server[edit | edit source]

To run your server, simply run your myserver.bat.

Stopping the server[edit | edit source]

  1. NEVER stop the server by closing the console. It will cause save issues.
  2. ALWAYS use /save in-game then follow up with /stop to stop the server.

Updating the server[edit | edit source]

  1. Stop the server by running the /save and /stop commands on the server.
  2. Backup your galaxies before updating.
  3. Locate steamcmd.exe and run the same command as you used to install the server, depending on Beta or Default:
    • Default: steamcmd.exe +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 validate +exit
    • Beta: steamcmd.exe +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 -beta beta validate +exit
  4. Now just start the server again by running myserver.bat

Switching between default and beta[edit | edit source]

This works exactly the same way as updating the server. Just choose the correct option when executing steamcmd.exe.

Please note that downgrading from beta to default most certainly WILL corrupt your galaxy files.

Setting up the Server (Linux)[edit | edit source]

Installing the Server FIles[edit | edit source]

  1. Install SteamCMD. (https://developer.valvesoftware.com/wiki/SteamCMD)
  2. Create a directory for the server files.
  3. Locate steamcmd and run it with the following arguments, depending on whether you want to run a default or beta server. Note that you need to replace <SERVER_PATH> with the path of the directory you just created.
    • Default: steamcmd +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 validate +exit
    • Beta: steamcmd +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 -beta beta validate +exit

Creating a Galaxy[edit | edit source]

This has to be done every time a new galaxy should be created:

  1. Locate and enter the directory of the server files (the one you created earlier).
  2. Run server.sh with the following command line options: ./server.sh --galaxy-name <GALAXYNAME> --admin <ADMIN> --datapath <GALAXY_PATH>
    1. <GALAXYNAME>: the name of your galaxy
    2. <ADMIN>: your 64bit SteamID to make sure you are the admin of the server
    3. <GALAXY_PATH>: the folder where the galaxies should be stored
  3. Wait for the server to finish initializing and then enter /save and /stop to stop the server. This initializes the galaxy config files.
  4. Open the server.ini of your galaxy. It is stored at <GALAXY_PATH>/<GALAXYNAME>.
  5. An explanation of the available settings in this file is available here.
  6. Save the file.
  7. Congratulations! You finished setting up your galaxy.

Starting the server[edit | edit source]

To run your server, run:

./server.sh --galaxy-name <GALAXYNAME> --admin <ADMIN> --datapath <GALAXY_PATH>

Stopping the server[edit | edit source]

  1. NEVER stop the server by closing the console. It will cause save issues.
  2. ALWAYS use /save in-game then follow up with /stop to stop the server.

Updating the server[edit | edit source]

  1. Stop the server by running the /save and /stop commands on the server.
  2. Backup your galaxies before updating.
  3. Locate steamcmd.exe and run the same command as you used to install the server, depending on Beta or Default:
    • Default: steamcmd +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 validate +exit
    • Beta: steamcmd +login anonymous +force_install_dir <SERVER_PATH> +app_update 565060 -beta beta validate +exit
  4. Start the server again

Switching between default and beta[edit | edit source]

This works exactly the same way as updating the server. Just choose the correct option when executing steamcmd.exe.

Please note that downgrading from beta to default most certainly WILL corrupt your galaxy files.

Further settings[edit | edit source]

The server will create a server.ini file and a few others, concerning blacklists, whitelists or user groups when it is started up. The files are located in the galaxy folder of the server. More detailed settings can be changed in there.

This file should only be edited when the server is not running, as the server will overwrite its settings in the file on shutdown.

Multithreading[edit | edit source]

The server supports several settings for multithreading:

  • Worker Threads
  • Generator Threads
  • Script Background Threads

Worker threads are the threads that update the simulation and do the main work. They will run the server.

Generator threads generate new or load old sectors as the players progress and explore the galaxy.

Script Background threads do heavy script calculations (created with the async() call) that might be necessary. One example would be generation of ship models.

General Recommendations for Multithreading Settings[edit | edit source]

In the following, hardware concurrency means the amount of threads that your machine can run at the same time. E.g.: A 4 core Intel CPU with hyperthreading has a hardware concurrency of 8, while a e.g. 6 core AMD without hyperthreading has a hardware concurrency of 6. You can look up your hardware concurrency in your task manager on windows, with htop on linux.

It's recommended to have as many worker threads as your hardware concurrency.

It's recommended to have at least 2 generator threads, but never as many as your hardware concurrency, since they might starve the worker threads, which leads to the simulation staggering, which leads to lagging. If you're running a large server with lots of players who like to explore, you can increase the amount of generator threads to decrease hyperspace calculation time. Generator threads will only run for a short time each, while generating a new sector or loading an old one from disk. It can't be predicted for how long they will run, sometimes it can be a few seconds, sometimes up to minutes.

Examples for different machines:[edit | edit source]

Machine: 4 core Intel CPU with Hyperthreading (hardware concurrency of 8):

  • 8 Worker Threads
  • 2 - 4 Generator Threads (for 5 - 15 players)
  • 2 Script Background Threads

Machine: 8 core Intel CPU with Hyperthreading (hardware concurrency of 16):

  • 16 Worker Threads
  • 4 - 8 Generator Threads (for 10 - 20 players)
  • 2 - 4 Script Background Threads

Machine: 6 core CPU without Hyperthreading (hardware concurrency of 6):

  • 6 Worker Threads
  • 2 - 3 Generator Threads (for 5 - 10 players)
  • 2 Script Background Threads

Machine: 16 core CPU with Hyperthreading (hardware concurrency of 32)

  • 32 Worker Threads
  • 8 Generator Threads
  • 2 - 4 Script Background Threads

Log File[edit | edit source]

The server will create log files when it is started up. The log files are located in the galaxy folder. They're called "serverlog [Date].txt". This logfile contains a lot of data concerning the activities on the server, such as a full chat log, or when which player logged in.

Finding Errors[edit | edit source]

Should your server not run properly, there are multiple options for checking what's wrong.

Log File[edit | edit source]

The log file does not only contain game-relevant data, but also a lot of technical data, such as connection problem diagnosis. You may want to check the log file for errors concerning the server.

Tracing[edit | edit source]

This option will make the server print a lot more output, but it may also hurt performance a lot. To enable this, start the server with the additional command line options -t all.

bin\AvorionServer.exe --datapath "C:\MyAwesomeGalaxy" --admin AwesomeUser -t all

Your server will now emit a lot more information while running, which may help you to debug any problems arising with it.

Remember: This will hurt performance of the server and should only be used for debugging purposes.