Server on Linux: Difference between revisions

From Eco - English Wiki
[checked revision][checked revision]
→‎Systemd service script: Replace HUP and INT signals with TERM -> more gracefule, allow the server to save world before exiting
Line 19: Line 19:
steamcmd +force_install_dir ~/Eco +login anonymous +app_update 739590 -beta default validate +quit
steamcmd +force_install_dir ~/Eco +login anonymous +app_update 739590 -beta default validate +quit
</syntaxhighlight>
</syntaxhighlight>
=== SLG Direct Download ===
=== SLG Direct Download ===
An archive of the current release of the Eco Dedicated Server as of this writing (Beta 9.4.1) can be found [https://play.eco/s3/release/EcoServerLinux_v0.9.4.1-beta.zip here]. The following series of commands will download the archive, and set the Eco Dedicated Server up in an <tt>Eco</tt> subdirectory of your home directory, and save a copy of the install archive into a <tt>dist</tt> subdirectory of your home directory:
An archive of the current release of the Eco Dedicated Server as of this writing (Beta 9.4.1) can be found [https://play.eco/s3/release/EcoServerLinux_v0.9.4.1-beta.zip here]. The following series of commands will download the archive, and set the Eco Dedicated Server up in an <tt>Eco</tt> subdirectory of your home directory, and save a copy of the install archive into a <tt>dist</tt> subdirectory of your home directory:
Line 97: Line 96:
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /gamesservers/eco +app_update 739590 default validate +quit
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /gamesservers/eco +app_update 739590 default validate +quit
ExecStart=/bin/bash -c 'cd /gamesservers/eco && exec /gamesservers/eco/EcoServer'
ExecStart=/bin/bash -c 'cd /gamesservers/eco && exec /gamesservers/eco/EcoServer'
ExecReload=/bin/kill -s HUP $MAINPID
ExecReload=/bin/kill -s TERM $MAINPID
ExecStop=/bin/kill -s INT $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
</syntaxhighlight>
</syntaxhighlight>
== Stopping the Server ==
== Stopping the Server ==
To safely shut down the Eco server, send SIGINT or press Control+C with the <tt>EcoServer</tt> process interactively to initiate a safe shutdown.
To safely shut down the Eco server, send SIGINT or press Control+C with the <tt>EcoServer</tt> process interactively to initiate a safe shutdown.

Revision as of 00:27, 21 January 2022

Important Foreward

First, a disclaimer: Strange Loop Games does provide a Linux server build, but they do not offer official support for it at this time. It is provided as a convenience, not a product.

If you run into trouble or have a question, you can make inquiries in the #server-help channel in the Eco Discord, but keep in mind the information above.

Prerequisites

Mono No More

Prior to version 9.0 of Eco, it was required that you run with a very old build (no later than 5.14) of the Mono development libraries, and use Mono to run the server. This is no longer the case.

.NET Core Libraries

Eco is now built with and is run leveraging .NET Core, and runs as a native binary on Linux. You will have to install the .NET Core 3.1 libraries, repositories for which Microsoft makes available for several Linux distributions. Follow the directions on Microsoft's site for instructions for installing the libraries.

Eco Dedicated Server files

There are two primary options for acquisition of the Eco dedicated server: getting it directly from Strange Loop Games, or through Valve Software's Steam platform.

Steam Command-Line Client

Getting SteamCMD

The ECO Dedicated Server is made available through Valve Software's Steam distribution system, and Valve provides a command-line tool called SteamCMD to facilitate command-line installation of products in various environments, including Linux. Follow the directions on the foregoing link to get the SteamCMD program installed and configured on your system. You will not need SteamCMD if you are acquiring the Eco Dedicated Server directly from Strange Loop Games.

Installing Eco with SteamCMD

Presuming for the same of simplicity that you wish to install the Eco Dedicated Server into an Eco subdirectory of your home directory, a script such as the following will install and subsequently update the software for you:

#!/bin/bash
steamcmd +force_install_dir ~/Eco +login anonymous +app_update 739590 -beta default validate +quit

SLG Direct Download

An archive of the current release of the Eco Dedicated Server as of this writing (Beta 9.4.1) can be found here. The following series of commands will download the archive, and set the Eco Dedicated Server up in an Eco subdirectory of your home directory, and save a copy of the install archive into a dist subdirectory of your home directory:

mkdir -p ~/Eco
cd ~/Eco
wget https://play.eco/s3/release/EcoServerLinux_v0.9.4.1-beta.zip
unzip EcoServerLinux_v0.9.4.1-beta.zip
mkdir -p ~/dist
mv EcoServerLinux_v0.9.4.1-beta.zip ~/dist/

Setting up the network

Setting up firewalld on your server

firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --zone=public --add-port=3000/udp --permanent
firewall-cmd --zone=public --add-port=3001/tcp --permanent

systemctl restart firewalld

Forwarding your router ports

To give other people access to your server you need to tell your router how to handle incoming request from certain ports that come from an external computer.

On an Asus router you can find these settings under Wan -> Virtual Server / Port Forwarding. ( I censored my own setup to keep my server secure but this should give some idea). First of all you need to set a name (Service name). The next item is the port range, on my router I would write 3000:3001 to give it the right range. Next item is the local IP - this should be your server IP. Leave the local port blank.

Starting the Server

Because the Eco Dedicated Server is now a native Linux binary, starting it could not be easier. Again, presuming it is installed in an Eco subdirectory of your home:

cd ~/Eco
./EcoServer

Systemd service script

If you wish to set up a systemd service to have ECO run automatically, this will do the trick:

Using your favorite editor (vi, nano etc.) edit /usr/lib/systemd/system/EcoServer.service and paste the following:

[Unit]
Description=Eco Server
[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
User=ecoserver
Group=ecoserver
Environment="DOTNET_BUNDLE_EXTRACT_BASE_DIR=%h/.net"
#ExecStartPre=/home/ark/server/steamcmd +login [username] +force_install_dir /home/ecoserver/Eco_server/ +app_update 739590 +quit
ExecStart=/bin/bash -c 'cd /home/ecoserver/Eco_server && exec /home/ecoserver/Eco_server/EcoServer'
ExecStop=killall -TERM srcds_linux
[Install]
WantedBy=multi-user.target

ExecStartPre is commented out because I was not able to get it to work without user input due to Steam Guard.

Then update the systemd service by running the following:

sudo systemctl daemon-reload

Enable the Systemd service:

sudo systemctl enable EcoServer

You can then optionally start, stop and check the status of the server with the following commands respectively:

sudo systemctl start EcoServer
sudo systemctl stop EcoServer
sudo systemctl status EcoServer

Debian/Ubuntu Version

[Unit]
Description=Westwoods Eco
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target

[Service]
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
User=eco
Group=eco
LimitNOFILE=100000
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /gamesservers/eco +app_update 739590 default validate +quit
ExecStart=/bin/bash -c 'cd /gamesservers/eco && exec /gamesservers/eco/EcoServer'
ExecReload=/bin/kill -s TERM $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target

Stopping the Server

To safely shut down the Eco server, send SIGINT or press Control+C with the EcoServer process interactively to initiate a safe shutdown.

Please not that this procedure doesn't work with Eco versions prior to 9.0.0-beta.

Docker

There is a Docker version of the server as well. You can pull the latest stable version using:

docker pull strangeloopgames/eco-game-server:latest

You can also find additional builds here:

https://hub.docker.com/r/strangeloopgames/eco-game-server

You will need to make sure that the Docker container is exposing the ports and map them to ports on the host that are open in the hosts firewall and router.

Troubleshooting

Missing GDI library

You may sometimes get a crash on an attempted initial startup with an error resembling the following:

Failed to load server, Exception was Exception: DllNotFoundException Message:Unable to load shared library 'libgdiplus' or one of its dependencies.

The solution to this error state is to simply install the missing library. On a Debian-derived host this can be done with:

sudo apt install libgdiplus

Connecting remotely

You may find that your server does not show up in a list for people outside of your local network, even if you have set "PublicServer": true and have opened the appropriate ports in your router (and firewall if enabled on your linux machine).

If this happens, try clicking on the "+" symbol in the "Your Worlds" area, then adding in the external IP and port you used (probably 3000). Unfortunately, https://www.yougetsignal.com/tools/open-ports/ does _not_ accurately reflect one's ability to connect to the server.