-
-
Save winny-/bb17853ffc76fbb9b039 to your computer and use it in GitHub Desktop.
Minecraft systemd unit file that uses tmux instead of screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@plex ~]# cat /etc/systemd/system/[email protected] | |
[Unit] | |
Description=Minecraft Server %i | |
[Service] | |
WorkingDirectory=/opt/minecraft-%i | |
User=mcserver | |
Type=forking | |
ExecStart=/usr/bin/tmux new-session -s mc-%i -d '/bin/java -Xmx2048M -jar minecraft_server.jar nogui' | |
ExecStop=/usr/bin/tmux send-keys -t mc-%i:0.0 'say SERVER SHUTTING DOWN. Saving map...' C-m 'save-all' C-m 'stop' C-m | |
ExecStop=/bin/sleep 2 | |
[Install] | |
WantedBy=multi-user.target | |
######### | |
# HowTo | |
######### | |
# | |
# Create directory in /opt/minecraft-XX where XX is a name like 'survival' | |
# Add minecraft_server.jar into dir with other conf files for minecraft server | |
# | |
# Enable/Start systemd service | |
# systemctl enable minecraft@survival | |
# systemctl start minecraft@survival | |
# | |
# To run multiple servers simply create a new dir structure and enable/start it | |
# systemctl enable minecraft@creative | |
# systemctl start minecraft@creative |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm just gonna leave this here https://superuser.com/questions/1581577/running-two-tmux-sessions-as-systemd-service/1582196#1582196