0

As a followup to one of my previous posts, I'm using systemd to run a GMod server on Ubuntu 18.04. My systemd script looks like this:

[Unit]
Description=Gmod Server
After=network.target

[Service]
User=rooday # the user I normally run run_gmod.sh with
ExecStart=/datadrive/srcds/run_gmod.sh
Restart=Always

[Install]
WantedBy=multi-user.target

and it runs my server fine, but the issue is that systemctl status and journalctl aren't showing the actual logs of the server binary.

This is because run_gmod.sh runs the srcds_run script (part of the srcds installation) with the parameters for my server (which gamemode, which map, etc). srcds_run takes these parameters and sets some environment variables, and then runs the actual server binary (as well as has some logic to restart the server binary after a crash, update the server, etc.).

srcds_run has a lot of logic so I don't want to bypass it and run the binary directly (unless someone more experienced with srcds servers thinks that's a better option), I'd rather just have systemctl and journalctl show the logs of the server binary. I tried using Type=forking but then running systemctl restart gmod would hang, so I'm not sure if that's the right option here. Does anyone know how to get the proper logs in systemctl/a better way to run the server?

ROODAY
  • 215
  • 2
  • 5
  • Perhaps add `StandardOutput=journal` under `[Service]`. – meuh Dec 28 '20 at 17:09
  • Unfortunately that didn't work, it resulted in the same logs as it did before. Is there a way to make systemd treat running a script the same as it would when running it normally as a user? Because if I run `run_gmod.sh` myself it starts the server console interactively and I can send commands to it, as well as see logs in real time (which is what I'd want in `journalctl`). – ROODAY Dec 28 '20 at 18:26
  • 1
    If you want to run a server that needs a console, typically people run `tmux` from the systemd Unit to start the server process. See this minecraft [example](https://superuser.com/q/1366001/458747). You can then run `tmux` at any time to connect to the server and interact with it, or scroll back over its output. – meuh Dec 29 '20 at 09:11

0 Answers0