Created
August 20, 2014 05:07
-
-
Save nathanielc/9b98350ccbcbf21256d7 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/[email protected] | |
[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
@Nirei Hi, I haven't used this gist in a few years now. I created this instead https://github.com/nathanielc/minecraft-multi-server. It serves my needs better. It uses docker instead of screen to background and manage the minecraft server processes. Maybe it can be of use to you as well.