2020-04-16 15:08:07 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-08-02 09:39:00 -04:00
|
|
|
# The alive checker and Minecraft server is started at the same time
|
2020-04-16 15:08:07 -04:00
|
|
|
|
2023-07-27 12:04:30 -04:00
|
|
|
# PATH="$HOME/framework/vendor/java/bin/:$PATH"
|
2020-04-16 15:08:07 -04:00
|
|
|
|
2020-08-02 09:39:00 -04:00
|
|
|
# Dump classes
|
2023-07-27 12:14:18 -04:00
|
|
|
java -Xshare:dump
|
2020-08-02 09:39:00 -04:00
|
|
|
|
2020-04-16 15:08:07 -04:00
|
|
|
# Make sure we're in the server folder, located in the home directory
|
|
|
|
cd ~/server/
|
|
|
|
|
|
|
|
while true; do
|
2022-04-09 07:37:18 -04:00
|
|
|
# Check if the server is stuck in a crash loop, and reset worlds if this is the case
|
|
|
|
# The alive checker resets server_stops.log if the server runs long enough
|
|
|
|
|
|
|
|
stop_log_file=server_stops.log
|
|
|
|
|
|
|
|
if [ -f "$stop_log_file" ] && [ "$(wc -l < $stop_log_file)" -gt 3 ]; then
|
|
|
|
rm -rf worlds/ plugins/FastAsyncWorldEdit/clipboard/ plugins/FastAsyncWorldEdit/history/
|
|
|
|
rm "$stop_log_file"
|
|
|
|
fi
|
|
|
|
|
2020-08-02 07:51:56 -04:00
|
|
|
# Make certain files and folders read-only
|
|
|
|
|
2024-06-24 22:42:25 -04:00
|
|
|
mkdir debug/ dumps/ plugins/update/ plugins/.paper-remapped
|
2021-03-02 15:38:57 -05:00
|
|
|
chmod -R 500 debug/ dumps/ plugins/bStats/ plugins/PluginMetrics/ plugins/update/
|
2024-06-24 22:42:25 -04:00
|
|
|
chmod 500 plugins
|
2020-08-02 07:51:56 -04:00
|
|
|
chmod 400 bukkit.yml
|
|
|
|
chmod 400 commands.yml
|
|
|
|
chmod 400 eula.txt
|
|
|
|
chmod 400 paper.yml
|
|
|
|
chmod 400 permissions.yml
|
|
|
|
chmod 400 server-icon.png
|
|
|
|
chmod 400 server.properties
|
|
|
|
chmod 400 spigot.yml
|
|
|
|
chmod 400 wepif.yml
|
|
|
|
|
|
|
|
# Start alive checker
|
|
|
|
|
2023-07-27 12:12:41 -04:00
|
|
|
dtach -n alivecheck ~/framework/script/alivecheck.sh
|
2020-08-02 07:51:56 -04:00
|
|
|
|
|
|
|
# Start Minecraft server
|
|
|
|
|
2020-08-02 08:17:00 -04:00
|
|
|
java \
|
2023-07-27 12:14:18 -04:00
|
|
|
-Xms1700M \
|
|
|
|
-Xmx1700M \
|
2022-05-21 12:37:07 -04:00
|
|
|
-XX:+UseG1GC \
|
|
|
|
-XX:+ParallelRefProcEnabled \
|
|
|
|
-XX:MaxGCPauseMillis=200 \
|
|
|
|
-XX:+UnlockExperimentalVMOptions \
|
|
|
|
-XX:+DisableExplicitGC \
|
|
|
|
-XX:+AlwaysPreTouch \
|
|
|
|
-XX:G1HeapWastePercent=5 \
|
|
|
|
-XX:G1MixedGCCountTarget=4 \
|
|
|
|
-XX:G1MixedGCLiveThresholdPercent=90 \
|
|
|
|
-XX:G1RSetUpdatingPauseTimePercent=5 \
|
|
|
|
-XX:SurvivorRatio=32 \
|
|
|
|
-XX:+PerfDisableSharedMem \
|
|
|
|
-XX:MaxTenuringThreshold=1 \
|
|
|
|
-XX:G1NewSizePercent=30 \
|
|
|
|
-XX:G1MaxNewSizePercent=40 \
|
|
|
|
-XX:G1HeapRegionSize=8M \
|
|
|
|
-XX:G1ReservePercent=20 \
|
|
|
|
-XX:InitiatingHeapOccupancyPercent=15 \
|
2020-08-02 08:17:00 -04:00
|
|
|
-Xss8M \
|
2020-08-02 13:14:02 -04:00
|
|
|
-XX:MaxDirectMemorySize=512M \
|
2023-07-27 12:14:18 -04:00
|
|
|
-Xshare:on \
|
2020-08-02 08:17:00 -04:00
|
|
|
-XX:+UseContainerSupport \
|
2022-05-21 12:37:07 -04:00
|
|
|
-XX:-UsePerfData \
|
2020-08-02 08:17:00 -04:00
|
|
|
-DPaper.IgnoreJavaVersion=true \
|
|
|
|
-Dpaper.playerconnection.keepalive=360 \
|
|
|
|
-DIReallyKnowWhatIAmDoingISwear \
|
2022-05-21 12:37:07 -04:00
|
|
|
-Dusing.aikars.flags=https://mcflags.emc.gs \
|
|
|
|
-Daikars.new.flags=true \
|
2020-08-02 08:17:00 -04:00
|
|
|
-jar server.jar nogui
|
2020-08-02 07:51:56 -04:00
|
|
|
|
|
|
|
# Stop alive checker (will be started again on the next run)
|
|
|
|
|
2023-07-27 12:12:41 -04:00
|
|
|
pkill -9 alivecheck.sh
|
2022-04-09 07:37:18 -04:00
|
|
|
echo $(date) >> "$stop_log_file"
|
2020-08-02 07:51:56 -04:00
|
|
|
|
|
|
|
# Ensure we don't abuse the CPU in case of failure
|
2020-04-16 15:08:07 -04:00
|
|
|
sleep 1
|
|
|
|
done
|