Can't start Minecraft server in tmux with systemctl

Peter W.

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]: [email protected]: 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]: [email protected]: 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]: [email protected]: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: Failed with result 'exit-code'.
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: 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]: [email protected]: Control process exited, code=exited status=1
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: Failed with result 'exit-code'.
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: 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]: [email protected]: 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]: [email protected]: Unit entered failed state.
Oct 11 21:34:45 kingcolour systemd[1]: [email protected]: 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?

virullius

systemd expects a service to stay running in the foreground in order to monitor it. When you run tmux detached, with -d, it forks a new process and returns the original command. I've not confirmed this with tmux and minecraft but try setting Type=forking in the Service section to tell systemd to track the child process forked from the command specified in ExecStart.

Side note: Are you sure you need tmux here? It's much simpler without.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

can't start lightdm without systemctl

From Dev

Minecraft for Windows 10 can't connect to local server on LAN

From Dev

working minecraft server can't be started with systemd ("no screen session found")

From Dev

flask - Server can't start

From Dev

RSelenium, Can't start server

From Dev

Foreverjs can't start server

From Dev

Can't start symfony server

From Dev

Can't start Apache in chroot with systemctl but can run it manually on my own from Bash with no issue

From Dev

My minecraft server running on a ubuntu VPS keeps crashing because "/start.sh" doesn't exist?

From Dev

Make screen start as Daemon for a Minecraft server

From Dev

Setting up Minecraft server to start and stop automatically

From Dev

Docker Container won't start with systemctl

From Dev

How can I reboot a server with systemctl if systemctl reboot fails?

From Dev

How to start a tftp server in ubuntu using systemctl start tftp command?

From Dev

JBoss AS 7 and MySQL - Can't start server

From Dev

Can't start the karma server in angular

From Dev

Wamp server can't start (orange icon)

From Dev

Can't start MySQL server for the first time

From Dev

isc-dhcp-server can't start

From Dev

I can't get rails server to start

From Dev

Ruby error, can't start the rails server

From Dev

Can't start MySQL server (database corruption)

From Dev

SAP Can't start application server

From Dev

Minecraft 1.12, server does not start. "Linux external server"

From Dev

systemctl .service can't read the environment variable

From Dev

Not able to Start rabbitmq server in centos 7 using systemctl

From Dev

Minecraft command block ops can't use

From Dev

Can't make desktop icon for Minecraft

From Dev

PHP - start a minecraft_server.jar in background on Windows

Related Related

  1. 1

    can't start lightdm without systemctl

  2. 2

    Minecraft for Windows 10 can't connect to local server on LAN

  3. 3

    working minecraft server can't be started with systemd ("no screen session found")

  4. 4

    flask - Server can't start

  5. 5

    RSelenium, Can't start server

  6. 6

    Foreverjs can't start server

  7. 7

    Can't start symfony server

  8. 8

    Can't start Apache in chroot with systemctl but can run it manually on my own from Bash with no issue

  9. 9

    My minecraft server running on a ubuntu VPS keeps crashing because "/start.sh" doesn't exist?

  10. 10

    Make screen start as Daemon for a Minecraft server

  11. 11

    Setting up Minecraft server to start and stop automatically

  12. 12

    Docker Container won't start with systemctl

  13. 13

    How can I reboot a server with systemctl if systemctl reboot fails?

  14. 14

    How to start a tftp server in ubuntu using systemctl start tftp command?

  15. 15

    JBoss AS 7 and MySQL - Can't start server

  16. 16

    Can't start the karma server in angular

  17. 17

    Wamp server can't start (orange icon)

  18. 18

    Can't start MySQL server for the first time

  19. 19

    isc-dhcp-server can't start

  20. 20

    I can't get rails server to start

  21. 21

    Ruby error, can't start the rails server

  22. 22

    Can't start MySQL server (database corruption)

  23. 23

    SAP Can't start application server

  24. 24

    Minecraft 1.12, server does not start. "Linux external server"

  25. 25

    systemctl .service can't read the environment variable

  26. 26

    Not able to Start rabbitmq server in centos 7 using systemctl

  27. 27

    Minecraft command block ops can't use

  28. 28

    Can't make desktop icon for Minecraft

  29. 29

    PHP - start a minecraft_server.jar in background on Windows

HotTag

Archive