-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminecraft-server.service
More file actions
37 lines (27 loc) · 1.8 KB
/
minecraft-server.service
File metadata and controls
37 lines (27 loc) · 1.8 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
# This is an example of the service file I use for my Server
# There are a bunch of mandatory values you must change in here
# Make sure you modify your sudoers file to allow the user defined below
# to start and stop the service without a password prompt
[Unit]
Description=A Minecraft server
[Service]
Type=forking
WorkingDirectory=/minecraft # change this to your server game directory
User=mc # change "mc" to your server username (dont use root!)
Group=mc # change "mc" to your user group
# you must change a few things in the "ExecStart" command below
# change: after "-dmS" you must change "mc" to whatever your screen session is/should be
# change: "-Xms6G" & "-Xmx6G" How much memory you allocate to Java
## see here for an explanation: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
# change: at the end, the path and name of the .jar file that runs ex: /minecraft/paperclip.jar
ExecStart=/usr/bin/screen -h 2048 -dmS mc java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar paperclip.jar
# you must change the value after "-S" on all the "ExecStop" commands below to the screen session name above (if you changed it)
ExecStop=/usr/bin/screen -S mc -X eval 'stuff "say SERVER SHUTTING DOWN in 10 seconds!"\\015'
# Wait 10 seconds before sending the shutdown command
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/screen -S mc -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 3 #not sure if this is needed...
Restart=on-failure
RestartSec=60s
[Install]
WantedBy=multi-user.target