-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (34 loc) · 1.15 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
[Unit]
Description=Minecraft Server - %i
After=network.target
ConditionPathExists=/srv/minecraft/%i
[Service]
WorkingDirectory=/srv/minecraft/%i
User=minecraft
Group=minecraft
Sockets=minecraft@%i.socket
StandardInput=socket
StandardOutput=journal
StandardError=journal
PrivateUsers=true
ProtectSystem=full
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
NoNewPrivileges=true
# Set default variables
Environment="MIN_MEM=1024M"
Environment="MAX_MEM=1024M"
Environment="JAVA_PARAMETERS=-XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10"
Environment="JAR_PATH=minecraft.jar"
# Override default variable values in environment file
EnvironmentFile=-/srv/minecraft/%i/systemd.conf
ExecStart=/bin/sh -c "/usr/bin/java -server -Xms${MIN_MEM} -Xmx${MAX_MEM} ${JAVA_PARAMETERS} -jar ${JAR_PATH} nogui"
ExecStop=/bin/sh -c "/bin/echo stop > /srv/minecraft/%i/systemd.stdin"
Restart=on-failure
RestartSec=60s
# this is necessary to keep systemd from killing the process before it exits after ExecStop is called
KillSignal=SIGCONT
[Install]
WantedBy=multi-user.target