0
I'm trying to automate my Minecraft server because having to manually wrangle tmux sessions gets really old after a while. Here's the systemd service file I wrote to help me with that:
[Unit]
Description=Minecraft Server: %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/servers/%i
User=minecraft
Group=minecraft
Restart=on-failure
ExecStart=/usr/bin/tmux new -s mc-%i -d '/usr/bin/java -Xms1G -Xmx6G -jar forge-universal.jar nogui' bash
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
Executing the ExecStart
line manually works perfectly, the Java process is neatly put into a detached tmux session that I can attach to at my leisure.
Trying start the server via systemctl start minecraft@creative
fails miserably, with dozens of error messages like these filling up the journal before finally failing:
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Service hold-off time over, scheduling restart.
Oct 11 21:34:45 kingcolour systemd[1]: Stopped Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: Starting Minecraft Server: private...
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Control process exited, code=exited status=1
Oct 11 21:34:45 kingcolour systemd[1]: Failed to start Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Failed with result 'exit-code'.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Service hold-off time over, scheduling restart.
Oct 11 21:34:45 kingcolour systemd[1]: Stopped Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: Starting Minecraft Server: private...
Oct 11 21:34:45 kingcolour systemd[1]: Started Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Control process exited, code=exited status=1
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Failed with result 'exit-code'.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Service hold-off time over, scheduling restart.
Oct 11 21:34:45 kingcolour systemd[1]: Stopped Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Start request repeated too quickly.
Oct 11 21:34:45 kingcolour systemd[1]: Failed to start Minecraft Server: private.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: minecraft@private.service: Failed with result 'exit-code'.
Since tmux swallows all the error messages that could've happened, I have no idea what could be going wrong. Has anyone encountered this before?
please add the output of
– Nordlys Jeger – 2018-10-11T19:36:02.543journalctl -u minecraft@creative.service -b
to your question. please edit your question and do not respond in the comments.Have added the last 20 lines of
journalctl
spam instead of just the last 7. – Peter W. – 2018-10-11T19:38:43.467What is the point of the
bash
argument at the end? It looks like you're giving 2 different commands to tmux to run? – mjb2kmn – 2018-10-11T19:50:31.093Goddammit. God flipping dammit. I was experimenting with different versions of the service file since none of them seemed to work, but I must've missed that part. Removing that errant
bash
makes the script work. – Peter W. – 2018-10-11T19:54:08.860