My objection is conceptual and technical; lots of hacks can work but shouldn’t be used in practice. Lots of things that shouldn’t be used in practice actually are. This is one of them, and a major pet peeve of mine whenever I have to wade the game server industry
Let me try to explain where I’m coming from. It’s a bit long, but basically, the reason I dislike this is because it doesn’t inter-operate with the rest of the Linux ecosystem well. I recognize it’s sometimes necessary for the less well designed game servers out there, but Minecraft has a much better interface. Let’s use it!
Less conceptually, your service currently fails to properly interact with the systemd journal to my knowledge, so all system monitoring software that uses the journal as its source of truth fundamentally can’t know what’s going on with Minecraft. This means that graphing user metrics and log monitoring isn’t possible without modding the game or tmux and writing additional code. journalctl -xe --unit minecraft
won’t give you useful logs.
By using forking
you are also actively violating the type contract you’re setting up with systemd - the application that calls fork()
is supposed to exit by itself shortly after the child is spawned. Systemd will not manage the tmux process, which means that we now have a service that isn’t actually controlled by our service manager. Most of the time this is fine, but there are edge cases, some of which you currently tape over in your module by setting the start/stop scripts.
This isn’t great - firstly, systemd should never consider the Minecraft service “started”, which means that you can’t use this service for composition (i.e., DependsOn
, Requires
and such won’t work). If it does consider the service started, then something else calls fork()
and exits and we now are tracking the wrong PID with systemd, which is an entirely different problem.
Also, the SIGTERM
signal that systemd normally sends is the standard way of asking Minecraft to shut down nicely, and it actually listens to this standard. Systemd has a variety of options for watchdogs that allow you to control and monitor this behavior, but by using tmux we throw it all out of the window, because tmux won’t receive the SIGTERM. You’re either relying on the fact that tmux will shut down by itself, or, as in this case, write scripts to talk to tmux interactively instead. In either case, if tmux has an issue but our server doesn’t, systemd can’t do its job correctly.
There are probably a variety of other issues that arise from this that I don’t see immediately off the top of my head - while it “works”, a lot of assumptions and standards are broken, and it’s a bit of a mess. A hack by definition.
Back to more conceptual things, tmux also comes with a fair bit of overhead; it’s a full GUI after all, designed to multiplex terminals as the name says. It’s not at all intended for this strange use case the game server community keeps abusing it for, and has a lot of features that go unused or can even interfere with this use case.