Created
October 11, 2020 22:31
-
-
Save altucor/54d63adbd4341f1dff0ae5d18c6f5e64 to your computer and use it in GitHub Desktop.
Minecraft systemd script
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@minecraft:~# cat /etc/systemd/system/minecraft.service | |
[Unit] | |
Description=Minecraft Server | |
After=network.target | |
Wants=network-online.target | |
StartLimitIntervalSec=500 | |
StartLimitBurst=5 | |
[Service] | |
Type=simple | |
WorkingDirectory=/root/minecraft_1_16_3/ | |
KillMode=none | |
#ExecStart=/root/minecraft_1_16_3/start.sh | |
ExecStart=/usr/bin/screen -D -m -S mc-0 /usr/bin/java -Xmx8192M -Xms8192M -jar /root/minecraft_1_16_3/server.jar nogui | |
#ExecStop=touch /root/overviewer/stop_file | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 15 SECONDS..."^M' | |
ExecStop=/bin/sleep 5 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 10 SECONDS..."^M' | |
ExecStop=/bin/sleep 5 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 5 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 4 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 3 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 2 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 1 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "say SERVER SHUTTING DOWN IN 0 SECONDS..."^M' | |
ExecStop=/bin/sleep 1 | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "save-all"^M' | |
ExecStop=/usr/bin/screen -p 0 -S mc-0 -X eval 'stuff "stop"^M' | |
ExecStop=/usr/bin/screen -X -S mc-0 quit | |
TimeoutStartSec=30 | |
TimeoutStopSec=300 | |
Restart=on-failure | |
RestartSec=30s | |
User=root | |
Group=root | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment