-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminecraft.service
More file actions
50 lines (40 loc) · 2.17 KB
/
minecraft.service
File metadata and controls
50 lines (40 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[Unit]
Description=Minecraft Server
Wants=network-online.target
After=network-online.target local-fs.target
# Retry failed starts but don't spam instant failures
StartLimitIntervalSec=60
StartLimitBurst=3
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft/
### ADD THESE OPTIONS WHEN USING MCSDNOTIFIER ################################
Type=notify
NotifyAccess=all
TimeoutStartSec=300
# Should be at least 5 seconds higher than Spigot's watchdog timeout
WatchdogSec=70
TimeoutStopSec=120
###############################################################################
# Always auto restart unless stopped with systemctl
Restart=always
# Remove leftover screen sockets from crashes
ExecStartPre=-/usr/bin/screen -wipe minecraft
# Unset WATCHDOG_PID which mismatches (since we run as a child of screen) and breaks sd_watchdog_enabled(3)
ExecStart=/usr/bin/screen -DmS minecraft -- /usr/bin/env -u WATCHDOG_PID /usr/bin/java -Xms2G -Xmx2G -XX:+AlwaysPreTouch -XX:+UseG1GC -XX:+DisableExplicitGC -jar server.jar nogui
# Uncomment ExecReload if you want to support reload with the fragile reload command
#ExecReload=/usr/bin/screen -S minecraft -p 0 -X stuff "reload confirm^M"
# Try to shutdown with /stop command first because SIGTERM/SIGINT handling is sketchy in many versions/forks; due to a
# design flaw in the logging library plugin loggers stop working (which is often mistaken for plugins not getting
# disabled; https://github.com/PaperMC/Paper/issues/5270#issuecomment-831399586). This issue has been worked around in
# Paper 1.19.2+ (https://github.com/PaperMC/Paper/pull/5592) and you can remove the ExecStop= lines.
ExecStop=/usr/bin/screen -S minecraft -p 0 -X stuff "stop^M"
# Workaround systemd issue #13284 that they won't address because ExecStop is a "legacy concept"
ExecStop=/bin/sh -c 'while kill -0 $MAINPID 2>/dev/null; do sleep 1; done'
# SIGINT works better because we're running in screen(1), and Paper 1.12+ (with JLine/TerminalConsoleAppender;
# https://github.com/PaperMC/Paper/pull/728) catches SIGINT without going through the shutdown hook,
# therefore not triggering the plugin loggers bug in <1.19.2.
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target