Skip to content

Instantly share code, notes, and snippets.

@markallenpark
Created March 7, 2022 18:12
Show Gist options
  • Save markallenpark/d5d6e29a4b2130ab581c2e32159ba528 to your computer and use it in GitHub Desktop.
Save markallenpark/d5d6e29a4b2130ab581c2e32159ba528 to your computer and use it in GitHub Desktop.
Systemd service wrapper for PaperMC
[Unit]
Description=PaperMC Server
After=network.target
[Service]
WorkingDirectory=/opt/paper
User=paper
Group=paper
Restart=always
ExecStart=/usr/bin/screen -DmS paper /usr/bin/java -Xms4G -Xmx4G -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 /opt/paper/paperclip.jar nogui
ExecStop=/usr/bin/screen -p 0 -S paper -X stuff "say SERVER SHUTTING DOWN IN 15 SECONDS. SAVING ALL MAPS...\n"
ExecStop=/bin/sleep 5s
ExecStop=/usr/bin/screen -p 0 -S paper -X stuff "save-all\n"
ExecStop=/bin/sleep 10s
ExecStop=/usr/bin/screen -p 0 -s paper -X stuff "say Maps saved, rebooting in 5 seconds...\n"
ExecStop=/bin/sleep 5s
ExecStop=/usr/bin/screen -p 0 -S paper -X stuff "stop\n"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment