papermc/templates/papermc.service.j2
author Luke Hoersten <luke@hoersten.org>
Wed, 01 Jul 2020 15:47:58 -0500
changeset 108 f00f45a9512d
parent 33 ad75fc2d2853
permissions -rw-r--r--
Optimized jvm flags for paper.

[Unit]
Description=PaperMC Server
Documentation=https://paper.readthedocs.io/en/latest/server/getting-started.html

Wants=network.target
After=network.target

[Service]
User={{papermc_user}}
Group={{papermc_user}}
WorkingDirectory={{papermc_dir}}
Restart=on-failure
RestartSec=20 5
# ExecStart=/usr/bin/java -Xms{{papermc_mem}} -Xmx{{papermc_mem}} -jar server.jar
# Optimizations from https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
ExecStart=/usr/bin/java -Xms{{papermc_mem}} -Xmx{{papermc_mem}} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui

PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true

[Install]
WantedBy=multi-user.target