Server on Linux: Difference between revisions

From Eco - English Wiki
[unchecked revision][checked revision]
No edit summary
(→‎Systemd service script: fixed examples to actually work correctly to shutdown the service. Removed foot-gun advice about SIGINT to shutdown cleanly.)
Tag: 2017 source edit
 
(25 intermediate revisions by 15 users not shown)
Line 1: Line 1:
Running an Eco [[server]] on the Linux operating system is not supported by [[Strange Loop Games]].
== Important Foreword ==
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.


Some Linux users have successfully run servers with certain tools, but they can have debilitating problems with new versions, which may require different workarounds each time.
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 ==
EcoServer is compiled natively for Linux but requires some packages.


If you have a support question regarding Linux servers, please join the #server-help channel in [https://discord.gg/eco Eco Discord], but keep in mind the information above.
To install the required packages for Linux, use:<syntaxhighlight lang="bash">
./install.sh
</syntaxhighlight>This will install the following packages:
* [https://www.mono-project.com/docs/gui/libgdiplus/ libgdiplus]


== User Guide: Running from a shell (linux/debian) with UI ==
* [https://www.gnu.org/software/libc/libc.html libc6-dev]
== 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 [https://steampowered.com Steam] distribution system, and Valve provides a command-line tool called [https://developer.valvesoftware.com/wiki/SteamCMD 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 <tt>Eco</tt> subdirectory of your home directory, a script such as the following will install and subsequently update the software for you:
<syntaxhighlight lang="sh">
#!/bin/bash
steamcmd +force_install_dir ~/Eco +login anonymous +app_update 739590 -beta default validate +quit
</syntaxhighlight>
=== 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:
<syntaxhighlight lang="sh">
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/
</syntaxhighlight>
== Setting up the network ==
=== Setting up firewalld on your server ===
<syntaxhighlight lang="bash">
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
</syntaxhighlight>
=== 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 <tt>Eco</tt> subdirectory of your home:
<syntaxhighlight lang="shell">
cd ~/Eco
./EcoServer
</syntaxhighlight>
== Systemd service script ==
You can choose to create the service either system-wide OR as a user based service. The latter you CAN do without root but if you can't sudo/be root to use the loginctl command it won't stay around when you're logged out, and won't start on boot.


''Note: This is a guide submitted by [[User:Simonmicro]], using Eco server version 0.7.5.2 on Ubuntu 18.04.1 LTS''
If you've visited this before, note the example service files have been changed to actually cleanly shutdown the Eco server!  The prior version of both examples in this Wiki would NOT correctly stop the server.
 
For system-wide setup you can do the following -- using your favorite editor (vi, nano etc.) edit /etc/systemd/system/EcoServer.service or /usr/lib/systemd/system/EcoServer.service (which depends on your platform, generally though /usr/lib/systemd is for installed packages, not local modifications) and paste the following making sure to update User, Group, WorkingDirectory, and ExecStart.
 
WorkingDirectory is going to be the root of your ECO server. If you'd normally start on the command line from /games/Eco then WorkingDirectory should be /games/Eco
<syntaxhighlight lang="shell">
[Unit]
Description=Eco Server
# The below may or may not work correctly depending on platform, it's important that systemd is asked to start this after networking is online at the very least.
After=syslog.target network.target nss-lookup.target network-online.target


If you want to run the eco server from a shell under linux with the UI for easier server configuration, you will need a virtual desktop environment. The following example will demonstrate a basic setup under linux (debian 9) using a minimalistic virtual desktop.
[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
User=ecoserver
Group=ecoserver
Environment="DOTNET_BUNDLE_EXTRACT_BASE_DIR=%h/.net"
WorkingDirectory=/home/ecoserver/Eco_server
# change to where your steamcmd exists if you want to automatically update on each restart.
#ExecStartPre=/home/ark/server/steamcmd +login anonymous +force_install_dir /home/ecoserver/Eco_server/ +app_update 739590 +quit
# ExecStart MUST be a full path!  IE starting with /
ExecStart=/home/ecoserver/Eco_server/EcoServer
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
Then update the systemd service by running the following:<syntaxhighlight lang="shell">
sudo systemctl daemon-reload
</syntaxhighlight>Enable the Systemd service:<syntaxhighlight lang="shell">
sudo systemctl enable EcoServer
</syntaxhighlight>You can then optionally start, stop and check the status of the server with the following commands respectively:<syntaxhighlight lang="shell" line="1">
sudo systemctl start EcoServer
sudo systemctl stop EcoServer
sudo systemctl status EcoServer
</syntaxhighlight>
You can also deploy using a systemd user service which means you won't need root to start/stop/restart. You'll have to remove the User and Group lines from the unit, and if you want it to start on boot you'll need to enable that for the user.


First you will need to install some required packages: vnc4server (the virtual desktop), lxde (minimalistic desktop), mono-devel (to execute .exe files).
As root or a user with sudo access (this step is critical when setting up the service as a user service if you do not want systemd to shut the server down every time you logout!!):
You can install them using the following command - maybe some packages can not found for your distribution (for that please see your distros documantation).
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
sudo apt install --no-install-recommends vnc4server mono-devel tigervnc-common lxde
sudo loginctl enable-linger ecoserv
</syntaxhighlight>
</syntaxhighlight>


Now you can run your VNC server using the following command - please take a look inside the printed log file to query the vnc listening port!
User based service unit example:
 
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
vncserver -localhost=no -geometry 1366x768
[Unit]
Description=Eco Server
# The below may or may not work correctly depending on platform, it's important that systemd is asked to start this after networking is online at the very least.
After=syslog.target network.target nss-lookup.target network-online.target
 
[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
Environment="DOTNET_BUNDLE_EXTRACT_BASE_DIR=%h/.net"
WorkingDirectory=%h/Eco_server
# change to where your steamcmd exists if you want to automatically update on each restart.
#ExecStartPre=/home/ark/server/steamcmd +login anonymous +force_install_dir %h/Eco_server/ +app_update 739590 +quit
# ExecStart MUST be a full path!  IE starting with /
ExecStart=%h/Eco_server/EcoServer
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=default.target
</syntaxhighlight>
</syntaxhighlight>


Now use a VNC client to connect to your server. If you are connected right-click to the desktop background to open a terminal. Inside the terminal you can start the desktop with a file manager using the following commands:
As the ecoserv user (or whatever user you choose) create the directory for the unit file(s) if it doesn't exist, and place the above unit file within that directory:
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
lxsession &
# creates the whole path if it doesn't exist
pcmanfm &
mkdir -p ~/.config/systemd/user/
# edit the file here ... ~/.config/systemd/user/EcoServer.service ... or whatever you name it, just as long as it ends in .service
systemctl --user daemon-reload
systemctl --user enable EcoServer
systemctl --user start EcoServer
</syntaxhighlight>
</syntaxhighlight>
Notice the --user flag to systemctl AND not using sudo. In a user service you can not set the User and Group, and the WantedBy target must be default.target so we remove/change those in the service file.  As a user service you can also use %h instead of /home/ecoserv (or whatever) to reference the user home directory, systemd will expand that for us.


[[File:Screenshot from vnc desktop.png|thumb|Lxde on VNC]]
'''Debian/Ubuntu Version'''
<syntaxhighlight lang="shell">
[Unit]
Description=Westwoods Eco
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target


Now navigate to your servers root (where EcoServer.exe is located) and right-click its file. Select "Mono Runtime (Terminal)" to run your eco server with its UI.
[Service]
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
User=eco
Group=eco
LimitNOFILE=100000
WorkingDirectory=/gameservers/eco
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /gamesservers/eco +app_update 739590 default validate +quit
ExecStart=/gamesservers/eco/EcoServer
ExecReload=kill -TERM $MAINPID
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target
</syntaxhighlight>


[[File:Screenshot from eco server startup.png|thumb|Screenshot to open a eco server with ui - vnc client connection ]]


Alternatively, you can use the already opened terminal to navigate to your folder and start the eco server with the following command:
==Stopping the Server==
To safely shut down the Eco server, send SIGTERM (saves world), SIGINT (immediate stop! does not save the world!) or press {{key|Ctrl+C}} with the <tt>EcoServer</tt> 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:
<syntaxhighlight lang="shell">
<syntaxhighlight lang="shell">
mono EcoServer.exe
docker pull strangeloopgames/eco-game-server:latest
</syntaxhighlight>
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:
<syntaxhighlight lang="sh">
Failed to load server, Exception was Exception: DllNotFoundException Message:Unable to load shared library 'libgdiplus' or one of its dependencies.
</syntaxhighlight>
The solution to this error state is to simply install the missing library. On a Debian-derived host this can be done with:
<syntaxhighlight lang="sh">
sudo apt install libgdiplus
</syntaxhighlight>
</syntaxhighlight>
===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).


Please not that this procedure doesn't work with eco server versions 7.6.0 and 7.6.1 (see https://github.com/StrangeLoopGames/EcoIssues/issues/8577)!
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.

Latest revision as of 18:24, 5 May 2022

Important Foreword[edit | edit source]

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 server, but keep in mind the information above.

Prerequisites[edit | edit source]

EcoServer is compiled natively for Linux but requires some packages.

To install the required packages for Linux, use:

./install.sh

This will install the following packages:

Eco Dedicated Server files[edit | edit source]

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[edit | edit source]

Getting SteamCMD[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

Setting up firewalld on your server[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

You can choose to create the service either system-wide OR as a user based service. The latter you CAN do without root but if you can't sudo/be root to use the loginctl command it won't stay around when you're logged out, and won't start on boot.

If you've visited this before, note the example service files have been changed to actually cleanly shutdown the Eco server! The prior version of both examples in this Wiki would NOT correctly stop the server.

For system-wide setup you can do the following -- using your favorite editor (vi, nano etc.) edit /etc/systemd/system/EcoServer.service or /usr/lib/systemd/system/EcoServer.service (which depends on your platform, generally though /usr/lib/systemd is for installed packages, not local modifications) and paste the following making sure to update User, Group, WorkingDirectory, and ExecStart.

WorkingDirectory is going to be the root of your ECO server. If you'd normally start on the command line from /games/Eco then WorkingDirectory should be /games/Eco

[Unit]
Description=Eco Server
# The below may or may not work correctly depending on platform, it's important that systemd is asked to start this after networking is online at the very least.
After=syslog.target network.target nss-lookup.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
User=ecoserver
Group=ecoserver
Environment="DOTNET_BUNDLE_EXTRACT_BASE_DIR=%h/.net"
WorkingDirectory=/home/ecoserver/Eco_server
# change to where your steamcmd exists if you want to automatically update on each restart.
#ExecStartPre=/home/ark/server/steamcmd +login anonymous +force_install_dir /home/ecoserver/Eco_server/ +app_update 739590 +quit
# ExecStart MUST be a full path!  IE starting with /
ExecStart=/home/ecoserver/Eco_server/EcoServer
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target

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

You can also deploy using a systemd user service which means you won't need root to start/stop/restart. You'll have to remove the User and Group lines from the unit, and if you want it to start on boot you'll need to enable that for the user.

As root or a user with sudo access (this step is critical when setting up the service as a user service if you do not want systemd to shut the server down every time you logout!!):

sudo loginctl enable-linger ecoserv

User based service unit example:

[Unit]
Description=Eco Server
# The below may or may not work correctly depending on platform, it's important that systemd is asked to start this after networking is online at the very least.
After=syslog.target network.target nss-lookup.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
Environment="DOTNET_BUNDLE_EXTRACT_BASE_DIR=%h/.net"
WorkingDirectory=%h/Eco_server
# change to where your steamcmd exists if you want to automatically update on each restart.
#ExecStartPre=/home/ark/server/steamcmd +login anonymous +force_install_dir %h/Eco_server/ +app_update 739590 +quit
# ExecStart MUST be a full path!  IE starting with /
ExecStart=%h/Eco_server/EcoServer
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=default.target

As the ecoserv user (or whatever user you choose) create the directory for the unit file(s) if it doesn't exist, and place the above unit file within that directory:

# creates the whole path if it doesn't exist
mkdir -p ~/.config/systemd/user/
# edit the file here ... ~/.config/systemd/user/EcoServer.service ... or whatever you name it, just as long as it ends in .service
systemctl --user daemon-reload
systemctl --user enable EcoServer
systemctl --user start EcoServer

Notice the --user flag to systemctl AND not using sudo. In a user service you can not set the User and Group, and the WantedBy target must be default.target so we remove/change those in the service file. As a user service you can also use %h instead of /home/ecoserv (or whatever) to reference the user home directory, systemd will expand that for us.

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
WorkingDirectory=/gameservers/eco
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /gamesservers/eco +app_update 739590 default validate +quit
ExecStart=/gamesservers/eco/EcoServer
ExecReload=kill -TERM $MAINPID
ExecStop=kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target


Stopping the Server[edit | edit source]

To safely shut down the Eco server, send SIGTERM (saves world), SIGINT (immediate stop! does not save the world!) or press Ctrl+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[edit | edit source]

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[edit | edit source]

Missing GDI library[edit | edit source]

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[edit | edit source]

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.