Systemd unit file only works for one instance name, not the other

1

There are two Minecraft servers running on my Debian server. In order to avoid all the busywork of manually coordinating multiple tmux sessions, I wrote a systemd unit file to do all of that for me:

[Unit]
Description=Minecraft Server: %i
After=network.target

[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Type=forking
RemainAfterExit=yes

#Restart=on-abnormal

ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx4G -jar forge-universal.jar nogui'

ExecStop=/usr/bin/tmux send -t mc-%i 'say SERVER WILL SHUT DOWN IN 10 SECONDS' ENTER
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/tmux send -t mc-%i 'stop' ENTER

[Install]
WantedBy=multi-user.target

There are two subdirectories in /opt/minecraft/servers/: private and otherserver. These directories' file listings look like this:

minecraft@server ~ # ls -la /opt/minecraft/servers/private/
total 39180
drwxr-xr-x  9 minecraft minecraft     4096 Dec 20 21:34 .
drwxr-xr-x  5 minecraft minecraft     4096 Dec 19 21:11 ..
-rw-r--r--  1 minecraft minecraft        2 Dec 20 21:33 banned-ips.json
-rw-r--r--  1 minecraft minecraft        2 Dec 20 21:33 banned-players.json
drwxr-xr-x 10 minecraft minecraft     4096 Oct 11 16:22 config
drwxr-xr-x  2 minecraft minecraft     4096 Oct 11 16:11 crash-reports
-rw-r--r--  1 minecraft minecraft      181 Oct 11 16:11 eula.txt
-rw-r--r--  1 minecraft minecraft  4888981 Oct 11 16:10 forge-1.12.2-14.23.5.2768-universal.jar
lrwxrwxrwx  1 minecraft minecraft       39 Oct 11 11:41 forge-universal.jar -> forge-1.12.2-14.23.5.2768-universal.jar
drwxr-xr-x  3 minecraft minecraft     4096 Apr 14  2018 journeymap
drwxr-xr-x  8 minecraft minecraft     4096 Apr 14  2018 libraries
drwxr-xr-x  2 minecraft minecraft     4096 Dec 20 21:32 logs
-rw-r--r--  1 minecraft minecraft      369 Oct 11 15:04 mapcrafter.conf
-rw-r--r--  1 minecraft minecraft 30222121 Oct 11 16:10 minecraft_server.1.12.2.jar
drwxr-xr-x  3 minecraft minecraft     4096 Oct 11 16:21 mods
-rw-r--r--  1 minecraft minecraft      271 Dec 20 21:33 ops.json
-rw-r--r--  1 minecraft minecraft      843 Dec 20 21:33 server.properties
-rw-r--r--  1 minecraft minecraft      322 Dec 20 21:32 usercache.json
-rw-r--r--  1 minecraft minecraft      112 Oct 13 23:18 usernamecache.json
-rw-r--r--  1 minecraft minecraft      171 Dec 18 22:07 whitelist.json
drwxr-xr-x 11 minecraft minecraft     4096 Dec 20 21:33 world

Executing systemctl start minecraft@otherserver results in a new tmux session for the user minecraft called mc-otherserver and a successfully started Minecraft server.

Executing systemctl start minecraft@private, on the other hand, does literally nothing. The command returns instantly, does not spawn a new tmux session, doesn't start a new Minecraft server, nothing. I checked whether the Minecraft instance was just crashing, but it's not that. Manually executing tmux new -s mc-private -d 'java -Xms1G -Xmx4G -jar forge-universal.jar nogui in the server's directory works flawlessly and starts the Minecraft server in a new tmux instance, as intended.

Curiously enough, both servers worked just a few days ago. I checked the changelogs for systemd and tmux, but as far as I can tell, they haven't actually been updated for Debian stable for some weeks.

Additionally, journalctl contains no information about my failing unit file at all, so I'm at a loss here. Does anyone know what could be causing this?

Peter W.

Posted 2018-12-20T22:10:27.160

Reputation: 706

Answers

2

Sigh. Turns out the minecraft@private service was listed as loaded failed failed in systemctl list-units, and was thus prevented from being started again.

Doing systemctl reset-failed fixed my problem.

Peter W.

Posted 2018-12-20T22:10:27.160

Reputation: 706