From 111ad618a4301f0cd54c2529f029651ef3e15f35 Mon Sep 17 00:00:00 2001 From: Vasilis The Pikachu Date: Fri, 27 Oct 2023 12:30:55 +0200 Subject: [PATCH 1/3] Make watchdog guide more noob friendly --- .../setup/server-hosting-tutorial.md | 38 +-------- .../setting-up-ss14-watchdog.md | 83 ++++++++----------- 2 files changed, 37 insertions(+), 84 deletions(-) diff --git a/src/en/general-development/setup/server-hosting-tutorial.md b/src/en/general-development/setup/server-hosting-tutorial.md index 386f7696d..b5205a61f 100644 --- a/src/en/general-development/setup/server-hosting-tutorial.md +++ b/src/en/general-development/setup/server-hosting-tutorial.md @@ -169,43 +169,7 @@ This is for people running their own codebase and server and/or those who want a [`SS14.Watchdog`](https://github.com/space-wizards/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. ### Installation -1. Download or clone the latest `SS14.Watchdog` source code (linked above) -2. Run `dotnet publish -c Release -r linux-x64 --no-self-contained`, replacing `linux-x64` with an identifier for your platform -3. Copy the `SS14.Watchdog/bin/Release/net6.0/linux-x64/publish` directory (check this path for your platform as necessary) to where you want to store your SS14 server files. - -### Configuration -Configure the watchdog to add servers. Edit `appsettings.yml` inside the installed watchdog directory. - -1. Uncomment and set `BaseURL`. This is the address that your game servers will use to communicate with the watchdog. The default value is fine for small setups. For example: - ```yml - BaseUrl: https://builds.spacestation14.io/watchdog/ - ``` - -2. At the bottom of the config file, add a `Servers` YAML block, and then a `Instances` block inside of that. Inside the `Instances` block, add a block for each server that you plan to serve from this watchdog. For example: - - ```yml - - Servers: - Instances: - wizards_den: # ID of your server. - Name: "Wizard's Den" # Name of the server - Note that this is NOT the name of the server on the hub, that is set for each server under game.hostname in their respective config.toml files. - ApiToken: "foobar" # A secret password that you make up (API token) for the watchdog to control this server (e.g. update, restart) - ApiPort: 1212 # API port OF THE GAME SERVER. This has to match the 1212 HTTP status API (described below). Otherwise the watchdog can't contact the game server for stuff. - - # Auto update configuration. This can be left out if you do not need auto updates. Example is for our officially hosted builds. - # See below for alternatives. - UpdateType: "Manifest" - Updates: - ManifestUrl: "https://central.spacestation14.io/builds/wizards/manifest.json" - - # Any environment variables you may want to specify. - EnvironmentVariables: - Foo: bar - wizards_den_two: - # Name of the second server - Name: "Wizard's Den 2" - # etc... - ``` +[`Refeer to this`](https://docs.spacestation14.com/en/server-hosting/setting-up-ss14-watchdog.html) for intructions on building and configuring Watchdog. ### Server Instance Folder diff --git a/src/en/server-hosting/setting-up-ss14-watchdog.md b/src/en/server-hosting/setting-up-ss14-watchdog.md index 892218ea0..a8934dab1 100644 --- a/src/en/server-hosting/setting-up-ss14-watchdog.md +++ b/src/en/server-hosting/setting-up-ss14-watchdog.md @@ -15,6 +15,10 @@ It is also worth going through the custom codebases section, especially if you i Some of it's sort of altered slightly. --> + + [`SS14.Watchdog`](https://github.com/space-wizards/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 @@ -26,6 +30,7 @@ You need to have: + ASP .NET Core 6 Runtime Both of these can be found at the [.NET 6 download page](https://dotnet.microsoft.com/en-us/download/dotnet/6.0). +On Linux/MacOS use your favourite package manager (apt, dnf, pacman, brew etc) ### 2. Build @@ -44,24 +49,8 @@ dotnet publish -c Release -r linux-x64 --no-self-contained The contents of `SS14.Watchdog/bin/Release/net6.0/linux-x64/publish` can then be copied to some other place. -### 3. Configure - -Before continuing, it is worth mentioning that the `SS14.Watchdog` executable assumes all configuration (such as `appsettings.yml`) and data is located in the current directory, not the directory the executable is in. - -As such, for simplicity in updating the Watchdog, you should arrange a directory as so: - -``` -bin/ : This is the /publish/ directory previously created. -instances/ : This directory contains one subdirectory for each instance you have defined, i.e.: -instances/ERZ2/ : Directory for game instance ID `ERZ2`. - See "Server Instance Folder" below for details on the insides of one of these. -appsettings.yml : The configuration for the Watchdog. - This should initially be copied from `bin/appsettings.yml`. -``` -The different aspects to the configuration are listed in the following sections. - -### 4. Run +### 3. Run Assuming you've followed the structure laid out above, you simply need to have a terminal at the "main directory", and run `bin/SS14.Watchdog`. @@ -177,15 +166,13 @@ Secondly, you may want to simply force a server to be restarted. These tasks can be achieved with the following commands: -`curl -v -X POST -u myInstance:spooky http://localhost:5000/instances/myInstance/restart` - -`curl -v -X POST -u myInstance:spooky http://localhost:5000/instances/myInstance/update` +`curl -v -X POST -u myInstance:ApiToken http://localhost:5000/instances/myInstance/restart` -Here, `spooky` is the `ApiToken` of the instance `myInstance`. +`curl -v -X POST -u myInstance:ApiToken http://localhost:5000/instances/myInstance/update` ## Update Types -### For Vanilla Servers +### Manifest Update ```admonish info The server still won't automatically be notified of updates, so see above for instructions. @@ -203,36 +190,16 @@ Servers: ManifestUrl: "https://central.spacestation14.io/builds/wizards/manifest.json" ``` -### "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 to `bin/`. - -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: - -```yml -Servers: - Instances: - example: - # (skipped...) - UpdateType: "Dummy" -``` - You will have to manually move files around and extract the server binaries. Note that you should not move around or attempt to delete the files of a running server. - ### Jenkins Updates @@ -279,6 +245,29 @@ Servers: JobName: "Star" ``` +### "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 to `bin/`. + +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: + +```yml +Servers: + Instances: + example: + # (skipped...) + UpdateType: "Dummy" +``` + ### Custom Auto Updates Not supported, but it should be relatively trivial to edit the code for `SS14.Watchdog` to add support for whatever update mechanism you need. See `UpdateProvider.cs`. From 424d0d8e1982713894429ece257689d14c73d24e Mon Sep 17 00:00:00 2001 From: Vasilis Date: Fri, 27 Oct 2023 12:39:41 +0200 Subject: [PATCH 2/3] Update setting-up-ss14-watchdog.md --- src/en/server-hosting/setting-up-ss14-watchdog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/en/server-hosting/setting-up-ss14-watchdog.md b/src/en/server-hosting/setting-up-ss14-watchdog.md index a8934dab1..788e29f2a 100644 --- a/src/en/server-hosting/setting-up-ss14-watchdog.md +++ b/src/en/server-hosting/setting-up-ss14-watchdog.md @@ -30,6 +30,7 @@ You need to have: + ASP .NET Core 6 Runtime Both of these can be found at the [.NET 6 download page](https://dotnet.microsoft.com/en-us/download/dotnet/6.0). + On Linux/MacOS use your favourite package manager (apt, dnf, pacman, brew etc) ### 2. Build From 01d5bd3305ad2bf2ccf764685c43b765e43bbb7f Mon Sep 17 00:00:00 2001 From: Vasilis Date: Sun, 29 Oct 2023 02:46:01 +0200 Subject: [PATCH 3/3] add systemd service --- .../setting-up-ss14-watchdog.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/en/server-hosting/setting-up-ss14-watchdog.md b/src/en/server-hosting/setting-up-ss14-watchdog.md index 788e29f2a..29c7c2fbc 100644 --- a/src/en/server-hosting/setting-up-ss14-watchdog.md +++ b/src/en/server-hosting/setting-up-ss14-watchdog.md @@ -336,6 +336,35 @@ nowish = datetime.datetime.now().isoformat() print(json.dumps({"builds":{nowish: {"time": nowish, "client": {"url": "", "sha256": ""}, "server": {"linux-x64": {"url": "http://localhost:9283/SS14.Server_linux-x64.zip", "sha256": ""}}}}})) ``` +## Systemd service + +To allow the service to automatically start up with the server, you can make a service file. It will look something like this. + +Of course, change it to the actual directory of your watchdog. + +```/etc/systemd/system/SS14.Watchdog.service``` +```toml +[Unit] +Description=SS14 Watchdog +After=network.target + +[Service] +ExecStart=/path/to/SS14.Watchdog +WorkingDirectory=/path/to +Restart=always +# This is used for git method to not fail instantly. +Environment="DOTNET_CLI_HOME=/tmp" + +[Install] +WantedBy=default.target +``` +Now reload your systemd daemon and enable the service as you normally would. + +``` +systemctl daemon-reload +systemctl enable --now SS14.Watchdog +``` + ## General Troubleshooting ### Server keeps restarting every 30 seconds