homelab/roles/minecraft/templates/minecraft.service.j2

29 lines
1.0 KiB
Plaintext
Raw Normal View History

2021-05-13 07:35:00 +00:00
[Unit]
Description=Minecraft Server: %i
2021-05-13 07:35:00 +00:00
After=network.target
[Service]
Type=simple
WorkingDirectory={{ minecraft_home }}/%i
2021-05-13 07:35:00 +00:00
User={{ minecraft_user }}
Group={{ minecraft_user }}
Restart=always
EnvironmentFile={{ minecraft_home }}/%i/environment.conf
2021-05-13 07:35:00 +00:00
ExecStart=/usr/bin/screen -DmS minecraft-%i \
${JAVA_HOME}/bin/java -Xms${JAVA_XMS} -Xmx${JAVA_XMX} -jar minecraft_server.jar nogui
ExecReload=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "reload"\\015'
ExecStop=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "say SERVER SHUTDOWN IN 30 SECONDS"\015'
2021-05-13 07:35:00 +00:00
ExecStop=/bin/sleep 15
ExecStop=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "say SERVER SHUTDOWN IN 15 SECONDS"\015'
2021-05-13 07:35:00 +00:00
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "say SERVER SHUTDOWN IN 5 SECONDS"\015'
2021-05-13 07:35:00 +00:00
ExecStop=/bin/sleep 5
ExecStop=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "save-all"\015'
2021-05-13 07:35:00 +00:00
ExecStop=/bin/sleep 1
ExecStop=/usr/bin/screen -p 0 -S minecraft-%i -X eval 'stuff "stop"\015'
2021-05-13 07:35:00 +00:00
ExecStop=/bin/sleep 3
[Install]
WantedBy=multi-user.target