Skip to content

Instantly share code, notes, and snippets.

@almino
Created August 5, 2023 21:01
Show Gist options
  • Save almino/bc081dc9230cbe2bed62201a1cb21499 to your computer and use it in GitHub Desktop.
Save almino/bc081dc9230cbe2bed62201a1cb21499 to your computer and use it in GitHub Desktop.
Start Minecraft Fabric server when Ubuntu starts

Copy minecraft.service to /etc/systemd/system/ start.sh goes in your Minecraft server folder.

[Unit]
Description=Minecraft Server
After=network.target
[Service]
Type=simple
User=almino
WorkingDirectory=/home/almino/Minecraft/Solo11
ExecStart=/home/almino/Minecraft/Solo11/start.sh
StandardOutput=file:/home/almino/Minecraft/minecraft.service.log
StandardError=file:/home/almino/Minecraft/minecraft.service.error.log
Restart=on-failure
RestartSec=1min
[Install]
WantedBy=multi-user.target
#!/bin/sh
set -eux
JAR="fabric-server-mc.1.20.1-loader.0.14.22-launcher.0.11.2.jar"
MEMORY="10G"
DIRECTORY=$( dirname "$0" )
chdir $DIRECTORY
screen -S minecraft -D -m sh -c "java -Xms$MEMORY -Xmx$MEMORY -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 --add-modules=jdk.incubator.vector -jar $JAR nogui"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment