Forked from nathanielc/gist:9b98350ccbcbf21256d7
Last active
January 12, 2018 21:13
-
-
Save dsmouse/f71b4c78f2dc20226e951ccb2baa6405 to your computer and use it in GitHub Desktop.
Minecraft systemd unit file
This file contains 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/minecraft@.service | |
[Unit] | |
Description=Minecraft Server %i | |
[Service] | |
WorkingDirectory=/opt/minecraft-%i | |
User=mcserver | |
ExecStart=/usr/bin/screen -DmS mc-%i /bin/java -Xmx2048M -jar minecraft_server.jar nogui | |
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015' | |
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015' | |
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015' | |
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