From 58c8bdec26afe37e0a8253beadf7200b83e54f2e Mon Sep 17 00:00:00 2001 From: bkloosterboer Date: Sun, 22 Jan 2023 16:29:22 -0600 Subject: [PATCH] systemd template and instructions (#508) * systemd template and instructions * clarify some intsructions, change a few systemd paramters * change targets --- docs/Running-the-server.md | 1 + docs/Server-configuration.md | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/docs/Running-the-server.md b/docs/Running-the-server.md index 4dc4a5f..52e6f66 100644 --- a/docs/Running-the-server.md +++ b/docs/Running-the-server.md @@ -12,6 +12,7 @@ There are currently two modes to run the Impostor server. The first way, Single 4. Extract the zip. 5. Modify `config.json` to your liking. Documentation can be found [here](Server-configuration.md) _(this step is mandatory if you want to expose this server to other devices)_ 6. Run `Impostor.Server` (Linux/macOS) or `Impostor.Server.exe` (Windows) +7. (OPTIONAL - Linux) Configure a systemd definition file and enable the service to start on boot - [systemd configuration](Server-configuration.md#systemd) Depending on your host you may also need to port forward Impostor to the internet. By default Impostor uses port **22023** and the **UDP** protocol. As port forwarding changes per host or router configuration, port forwarding is not covered by this guide. diff --git a/docs/Server-configuration.md b/docs/Server-configuration.md index 65b2992..642c0bc 100644 --- a/docs/Server-configuration.md +++ b/docs/Server-configuration.md @@ -93,3 +93,69 @@ IMPOSTOR_Server__ListenPort=22023 IMPOSTOR_AntiCheat__Enabled=true IMPOSTOR_AntiCheat__BanIpFromGame=true ``` + +# systemd + +Linux users will likely want to create a systemd service definition to manage running the Impostor application. Benefits to using a systemd service include the following: + +- The server process can automatically restart if the process dies +- Impostor can be set to start on boot (handy if you do system updates regularly) +- You can use systemd targets to ensure the process doesn't start until the system dependencies are met + +Using your favorite text editor, create the following service file: + +``` +sudoedit /etc/systemd/system/impostor.service +``` + +Modify the following template to your needs and populate the service file. + +``` +[Unit] +Description=Impostor private Among Us server - https://github.com/Impostor/Impostor + +[Service] +# Directory where Impostor is installed +WorkingDirectory=/opt/impostor +# Path to Impostor binary +ExecStart=/opt/impostor/Impostor.Server +Restart=always +# Restart service after 10 seconds if the dotnet service crashes +RestartSec=10 +KillSignal=SIGTERM +SyslogIdentifier=impostor + +# User and group that will run the Impostor server process -- ensure that user is allowed to execute the binary +User=impostor +Group=impostor +TimeoutStopSec=10 + +[Install] +# Wait until most system services have started before starting Impostor +After=multi-user.target +WantedBy=multi-user.target +``` + +Reload all systemd unit files to source in the new file you've created. + +``` +sudo systemctl daemon-reload +``` + +Start the service. + +``` +sudo systemctl start impostor.service +``` + +Check the log for the service and verify it has started correctly -- Hint: Use the Q key to quit out of journalctl. + +``` +sudo journalctl -u impostor.service +``` + +If everything has started correctly, ensure the service is set to start on boot. + +``` +sudo systemctl enable impostor.service +``` \ No newline at end of file -- 2.39.5