Before jumping in the deep end here, you may want to at least go through hosting a vanilla server and learn how to administrate it.It may also be useful to familiarize yourself with setting up a developer environment, as you will need at least
dotnet installed to compile the Watchdog, and Python installed to run certain server build scripts.It is also worth going through the custom codebases section, especially if you intend to use any of these with a custom codebase.SS14.Watchdog (codename Ian) is our server-hosting wrapper thing, similar to TGS for BYOND (but much simpler for the time being). It handles auto updates, monitoring, automatic restarts, and administration. We recommend you use this for proper deployments.
Setup Process
1. Check Prerequisites
You need to have:- .NET 10 SDK
- ASP .NET Core 10 Runtime
2. Build
The following set of commands should build the Watchdog on a Linux system. You’ll have to adjust it according to your actual system, of course.SS14.Watchdog/bin/Release/net10.0/linux-x64/publish can then be copied to some other place. You will continue your work here.
3. Run
Assuming you’ve followed the structure laid out above, you simply need to have a terminal in the folder you copied above, and run theSS14.Watchdog executable.
Watchdog Configuration
Watchdog’s config file isappsettings.yml
The watchdog configuration is split into two major sections:
- Global elements, shared across all instances (servers).
- Per-instance elements.
Serilog, AllowedHosts
These shouldn’t usually need to be changed, and are too complex to describe here.BaseUrl
This represents the external URL of the Watchdog. This is passed to the instances automatically so that they can check in with the Watchdog. It’s also used in update modes which require clients to connect to the Watchdog for assets.Urls
This controls on which interfaces the Watchdog hosts, which may be important in some cases. In particular, this can be used to expose the Watchdog outside of localhost without a reverse proxy, as so:Notifications
You can now set a notification discord webhook to receive notifications whenever a server crashes, the integration is as simple as adding the following to your config.Instances
Each instance is a separate game server, so the terms “instance” and “server” can be used semi-interchangably.Server Instance Folder
The watchdog will automatically create a folder structure for each server instance. This is atinstances/<instanceId>, e.g. instances/wizards_den / instances/wizards_den_two, relative to the current working directory when executing the watchdog. In the example config above this would be instances/example
Each instance folder has the following files and folders:
binaries/: Is used to store client binaries when using the “Local” update type, see below.bin/: Contains the actual extracted server binaries.data/: Stores server data like player preferences.config.toml: Is the config file the server will load (the watchdog overrides the default location,server_config.tomlnext to the .exe, to avoid it getting deleted when the server resets). You may have to create this file manually the first time.data.json: Contains watchdog information. If you changed the update type and are getting errors, delete this.
Note that although the watchdog handles server updates you may still want to setup the config.toml as per the server operator’s handbook.
Controlling The Watchdog
There are two key situations when the watchdog needs to be controlled. Firstly, the watchdog will only update when it is either explicitly notified to check for an update, or when it is restarted. Secondly, you may want to simply force a server to be restarted. Lastly, you may want to shutdown the server when the round ends. Example for maintenance. These tasks can be achieved with the following commands:curl -v -X POST -u myInstance:ApiToken http://localhost:5000/instances/myInstance/restart
curl -v -X POST -u myInstance:ApiToken http://localhost:5000/instances/myInstance/update
curl -v -X POST -u myInstance:ApiToken http://localhost:5000/instances/myInstance/stop
Update Types
Manifest Update
The server still won’t automatically be notified of updates, so see above for instructions.
Git-based Updates
Git-based update method is unmaintained. While it’s the easiest to get started we can’t really help you if it breaks. You are mostly on your own.
This requires the server to have the necessary parts of the developer environment.
Also, you still need to write a Git hook or somesuch to ensure that the Watchdog is notified of the updates, or otherwise cause it to periodically check for updates.
Jenkins Updates
This is an ancient method, but it should still work.”Dummy” Update Provider
The “Dummy” update provider will fake an update whenever it is queried, and otherwise simply assume that a server has already been extracted tobin/.
As the Watchdog does not automatically periodically check for updates, the fake updates shouldn’t get in the way.
To configure this, use the following update configuration in your appsettings.yml, in the entry for your server instance:
Custom Auto Updates
Not supported, but it should be relatively trivial to edit the code forSS14.Watchdog to add support for whatever update mechanism you need. See UpdateProvider.cs.
Update Types (DIY Edition)
“Dummy” Update Provider, DIY Updates Edition
Before trying this, ensure you’re familiar with how to use the “Dummy” Update Provider in general. It is relatively simple to configure things in such a way as to allow for updates. The following instructions are for Unix-likes, but the idea should be comprehensible in any case. Start with configuring as so:switchTo, switchTo1 and switchTo2, are needed:
switchTo:
switchTo1:
switchTo2:
chmod +x switchTo*), and one of them is run, running ./switch after that will toggle between the two directories.
As such, the workflow is to remove everything in inactiveBin, then extract a new server there, then run ./switch to confirm it.
Before clearing and extracting a new server build to inactiveBin, be sure to make sure the server has actually restarted from any previous update and is actually no longer using that directory.
DIY Manifest Server
This is a quick script useful in setting up a DIY server for the Manifest update type described in the manifest section. It assumes you have some arbitrary static HTTP server, and you just need a script to output the JSON with an updated date (so you can just transfer two files to said static HTTP server and trigger an update).Systemd service
To allow watchdog to run in the background and automatically start up with the server, you can make a service file. It will look something like this. Of course, configure it to the actual directory of your watchdog. If your distro does not use systemd as it’s init then you will have to convert this to your relevent init.Due to how services work you wont be able to use the SS14 server console directly from your terminal if need be. Ensure you have given yourself permissions on your server so you can use the
sudo or > commands to run commands on the server./etc/systemd/system/SS14.Watchdog.service
Server persistence
Modifying the watchdog’s configuration or updating the watchdog requires it to be restarted, and by default, that means restarting all game servers running under the watchdog. Since commit6194ed4, the watchdog now supports server persistence. This allows it to be independently restarted, without affecting the game servers themselves.
To configure this, you can add the following to your appsettings.yml:
Systemd
When hosting the watchdog as a Systemd service, the above is not enough. With Systemd’s default settings, restarting the watchdog would cause Systemd to also kill the game server processes itself. This can be avoided by setting the following in your service definition:systemctl stop ss14-watchdog will not stop game servers, even if they are misbehaving/stuck.
General Troubleshooting
Server keeps restarting every 30 seconds
This means the server isn’t communicating with the watchdog correctly and the watchdog is forced to assume that the server is locked up or similar. This happens ifBaseUrl in the watchdog configuration is set incorrectly or otherwise inaccessible by the game server.
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Posix.NETStandard, Version=1.0.0.0, Culture=neutral (…)
Current working theory is that this is caused by improper dotnet publish options.
The below set of test results should help explain.
Mono.Posix.NETStandard.dll to mark executables as executable on Linux and Mac OS X, it’s important to have it around on those OSes.