Implement crash loop detector

This commit is contained in:
kaboom 2022-04-09 14:37:18 +03:00
parent 98aaae55ed
commit 3443b8c5a2
2 changed files with 14 additions and 0 deletions

View File

@ -13,5 +13,8 @@ while true; do
if [ "$(env printf '\xFE' | nc -w 15 0.0.0.0 25565 | wc -m)" -eq 0 ]; then
pkill -9 java
echo $(date) >> ~/kill.log
else
# Server is still running, reset the crash loop detector
rm ~/server/server_stops.log
fi
done

View File

@ -11,6 +11,16 @@ java -Xshare:dump
cd ~/server/
while true; do
# 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
# Make certain files and folders read-only
mkdir debug/ dumps/ plugins/update/
@ -46,6 +56,7 @@ while true; do
# Stop alive checker (will be started again on the next run)
pkill -9 alivecheck.sh
echo $(date) >> "$stop_log_file"
# Ensure we don't abuse the CPU in case of failure
sleep 1