Running a server/Advanced

From Sven Co-op
< Running a server
Revision as of 21:22, 22 December 2020 by AdamR (talk | contribs) (Category.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This section will go over some more advanced topics on running a server. Do not try anything here that you do not understand first.

1 Server administrators

Sven Co-op has a (minimal) framework for server administrators and owners to get some representation of their status and some basic functionality to help control the game session.

These players are given this status by declaring their Steam ID within the file adminsfile (pointing to "admins.txt" by default). To give a player administrative status simply write their Steam ID on a line in this file. You can write comments after if you want to keep note of the players' handle.

Server administrators will be shown as such on the score board with the icon Server administrator. If the server is yours you can also denote yourself as such by placing an asterisk * before your Steam ID, for which you will get a tinted icon Server owner. No additional functionality is currently available to owners, it's mainly for show.

Here is an example of how your administrator list file could look:

// Owners/operators
*STEAM_9:1:488201   # Paul (owner)
*STEAM_9:0:38195    # Jane

// Administrators
STEAM_9:0:95482     # Dave
STEAM_9:1:5828645   # Emily
STEAM_9:1:1522834   # sUpErDeAn
STEAM_9:0:864923    # Zamnuzi

You do not have to include your Steam ID if you are only going to be running a listen server (e.g.. for a temporary map test session). As a player hosting a listen server, you are automatically given the ownership status.

The only administrative functionality built-in currently provided is the ability to use cheat commands, primarily because this feature is fairly new to the game. We will be including more functionality in future releases, however our scripting platform is able to determine if a player is an administrator or owner. Anyone can write a server plug-in script to boost the functionality available without a complicated permissions base.

2 Server commands

Sven Co-op has server commands that can be used to manage servers better. Some of these are simply CVAR's you can change at run time, while others are pure commands.

Command Parameters Description
kicksteamid "Steam ID" Kicks a players based on their Steam ID case-insensitively. You must surround the Steam ID with quotes.
mp_nextmap_cycle Map name Sets the next map for the server. Players will see this in the score board when a next board full refresh happens. (Typically when respawning.)

3 Multiple server instances on a single installation

You do not have to have multiple installations of Sven Co-op or Sven Co-op Dedicated Server in order to run multiple game server instances. A single installation can hold multiple configurations, and a set of command line parameters can determine which set to use.

This comes with some pros and cons.

Advantages Disadvantages
  • Less time spent installing and maintaining multiple copies of your server.
  • Less time spent installing and maintaining custom content.
  • Less disk space consumed due to only needing a single set of game files.
  • Less effort required modifying/repairing game files.
  • Each process can choose to use a specific or shared configuration file.
  • Inability for instances to have the same map with different entities without map duplication.
  • Inability to limit a process to a specific set of game files.
  • Not always suitable for different people/groups to run servers on the same machine, targeted for one person/group.
  • Configurations must be within the game folder.

Multi-server configuration is intended for people who want to run multiple game server instances of the same game on a single computer (maybe a LARGE server with many processors) without the hassle of multiple installations. This is very common on game service providers or large clans/guilds.

First, navigate to the svencoop folder on your server installation. There will be a folder called servers already. Any files you place in this folder are intended to be shared among all game server instances. Create a sub-folder for each game server process you want to have. (There is no limit to how many you can have.)

There is already an example set of shared configuration files and a server specific configuration set for you to work from. Start by cloning the example folder. This diagram shows how your server configurations should be laid out.

Example profiling folder structure

You can actually organise your configurations however you like, but this example is a good way of keeping them tidy.

Each configuration folder will then have it's own set of configuration files inside. You don't have to use all of them, but a unique servercfgfile is pretty much essential. A logs folder will also be needed if you ever intend on using the log files again.

If you intend on using both a server specific and shared file (e.g.. banned.cfg) you must use your server-specific servercfgfile to execute each file. You will generally want to execute the shared one first, then the server specific one after. Only configuration files (.cfg) can be shared or bequeathed.

Next all you have to do is sort out your command line parameters to use the profiles you've created. This is very easy to do when running your server as unattended services either manually created or through FireDaemon, ServerDoc, or mEAn Loader. Otherwise make a new file "start.cmd" or "start.sh" in the server's configuration folder and put the command in here instead.

Here are some examples of command line parameters that go after svends.exe (Windows) or ./svends_run (Linux). You must change the working directory to the game server root first.

  • -console -port 27015 +maxplayers 12 +servercfgfile "servers/classic_cycle/server.cfg" +logsdir "servers/classic_cycle/logs" +map "_server_start" +log on
  • -console -port 27025 +maxplayers 12 +servercfgfile "servers/custom_cycle/server.cfg" +logsdir "servers/custom_cycle/logs" +map "_server_start" +log on
  • -console -port 27035 +maxplayers 12 +servercfgfile "servers/fun_cycle/server.cfg" +logsdir "servers/fun_cycle/logs" +map "_server_start" +log on
  • -console -port 27045 +maxplayers 6 +servercfgfile "servers/private_test/server.cfg" +logsdir "servers/private_test/logs" +map "_server_start" +log on

You can also profile other common files such as Metamod's plug-in list (plugins.ini) and AMX mod X's configuration (core.ini). This can be done by adding the following parameters:

  • +localinfo mm_pluginsfile "servers/yourprofile/metamod-plugins.ini"
  • +localinfo amxx_cfg "servers/yourprofile/amxx-core.ini"

You can then point your AMXX configuration files in the amxx-core.ini to files that sit within your profile folder.

4 Running a server as a service

Although there is no built-in support for running a Sven Co-op server as a Windows or Linux unattended service you can do this with the aid of a wrapper. These come in various forms, such as scripts, standalone executables, and full utility applications.

Before you begin you absolutely should create a user account on your system to run your service as. No matter which platform you are running, be it a Windows, Linux, or otherwise, you should never run a non-system application in an administrative or super user security context, e.g. "SYSTEM", "LOCAL SERVICE", or "root". Doing this creates a serious security vulnerability on your system.

If you are doing this on Windows you will have difficulty doing this on starter or home editions of Windows, because the local security policy management console will not be available to you. You will need to be running the professional/business, enterprise, or ultimate edition of Windows, or any of the Windows Server editions.

4.1 Windows

First create a user to run SvenDS on:

  1. Create a standard user account with a sensible name like "SvenDS" or "svc.svends", but don't forget the password. (You'll need it later.)
  2. Ensure this user is not in any administrative user groups, such as "Administrators", "Domain Admins", or "Enterprise Admins".
  3. Configure a local security policy, be it local or domain managed, so that in the user rights assignment section this user is listed within login as a batch job and login as a service.

4.1.1 FireDaemon Pro

FireDaemon Pro is a utility to make any Windows executable run as if it were a service. Although there are more minimal ways of doing this you will be hard pushed to find such a complete solution packed with features to help you get services up and automate them quickly. Particular advantages include:

  • Server will start automatically with Windows without any need to login.
  • Server process will be monitored for freezes and unexpected closure, with automatic restart.
  • Scheduling of running time and automatic restarting.
  • Respond to Windows messages boxes even if the console window is hidden.
  • Limit CPU core/thread affinity and priority.

A complete guide for installing SvenDS via SteamCmd and setting up a FireDaemon Pro managed service is available from FireDaemon's knowledge base.

FireDaemon Pro is offered on a 30 day trial basis, though if you run any game server on a full time basis the value of a full license will emerge rapidly. The license model is per server/VM -- you are not limited to the number of services you make/run.

4.1.2 (mEAn) ServerLoader

(mEAn) ServerLoader is an application designed to get a game server process running as a service with minimal effort. It doesn't offer many features other than this, in fact the only automation will be automatic restart if the server process closes. (No monitoring of frozen processes.)

(mEAn) ServerLoader is offered on a freeware basis. Installation steps are as follows:

  1. Download (mEAn) ServerLoader.
  2. Extract the ZIP file to your SvenDS installation area. (A directory "meanloader" will be created within.)
  3. Using the example configuration file below, create a file called "meanloader.ini" alongside your "server.cfg" file and populate it for your requirements.
  4. Open a command prompt to the "meanloader" directory.
  5. Run the following commands:
    • meanloader.exe --install
    • sc config svends start= auto DisplayName= "Sven Co-op dedicated server" obj= ".\SvenDS" password= TheServiceUserPassword
    • sc failure svends reset= 0 actions= restart/60000/restart/60000/restart/60000
    • sc description svends "Sven Co-op dedicated server launched via (mEAn) ServerLoader"

Your service will now be installed. To start/stop this service you can either use the services management console, or use the "sc" command, e.g. "sc start svends" or "sc stop svends".

Example configuration file:

[Settings]
ServiceName = svends
RestartInterval = 3000
NumberOfProcesses = 1
ServicePriority = Low
UserInterface = No

[Process_0]
StartDir = C:\SvenDS
ProcessName =
AppName = C:\SvenDS\SvenDS.exe
CommandLine = -console -game svencoop -secure +ip "1.2.3.4" -port 27015 -noipx +maxplayers 12 +log on +map "_server_start"
StartPause = 1000
StopPause = 1000
UserInterface = No
AutoRestart = Yes
Priority = normal
Paused = No
Window = Hide
NumOfRespChecks = 1
PrcFileLogging = No

If you are running multiple servers via configuration profiling you will be required to perform this installation for each individual server configuration profile you have. That means you must extract the utility into each configuration profile directory, as the utility itself does not offer any pointer to an INI file. (The INI file must reside in the same directory as the EXE.)

Be sure to use a different service name and description for each of your server profiles.

While this utility is capable of managing multiple processes, you cannot opt to start/stop/pause specific servers -- it's either all running or none running.

4.2 Linux

First create a user to run SvenDS on:

  1. Simply creating a basic user account, usually with useradd, will do. Naming it "svends" or "svc.svends" would be sensible.
  2. Ensure this user is not in any administrative user groups, such as "root", "sudo", or "wheel". Do not add it to a "sudoers" list either.

No further configuration of the user is required. It doesn't even need a password unless you plan to run any command terminals (e.g. Bash over SSH) for management purposes, though as a system administrator you should simply switch yourself to that user via command "sudo -i -u svends" instead.

4.2.1 Bash script

A Bash script can create a service utilising the "screen" utility to keep the process running behind the scenes. Currently this is compatible with Debian 9 "Stretch" and Debian 10 "Buster", though derivatives such as Ubuntu will likely be 100% compatible. This has not been tested with non-Debian derived distributions, such as RHEL/CentOS or Arch/Manjaro.

The following steps will need to be actioned for each server configuration profile:

  1. Save File:Service.sh into your server configuration profile directory. (E.g. svencoop/servers/server1.)
  2. Edit your saved "service.sh" file to match the name/path for your server configuration profile. (NAME, LISTEN_ADDRESS, LISTEN_PORT, and MAX_PLAYERS variables.)
  3. Open a command terminal to your server configuration profile directory.
  4. Make it executable with command "chmod 0750 service.sh".
  5. Run command "service.sh install" as super user to install your service.
  6. Run command "service svends-server1 start" as the service user to start your service, replacing "server1" with your server configuration profile name.

You can replace start for one of the following:

  • As super user:
    • install: Installs the service.
    • uninstall: Stops and un-installs the service.
  • As service user:
    • start: Starts the service.
    • restart: Stops and starts the service.
  • As service or super user:
    • stop: Stops the service.
    • status: Shows if the service is running or not.