2020-04-16 15:08:07 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# The following script is a failsafe for killing the Minecraft server if it happens
|
|
|
|
# to be stuck
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
sleep 420
|
|
|
|
|
2021-11-19 10:39:07 -05:00
|
|
|
# If the server doesn't respond to ping, kill it
|
2020-04-16 15:08:07 -04:00
|
|
|
|
2024-10-12 23:55:51 -04:00
|
|
|
if [ "$(env printf '\xFE' | nc -w 15 0.0.0.0 17891 | wc -m)" -eq 0 ]; then
|
2020-04-16 15:08:07 -04:00
|
|
|
pkill -9 java
|
|
|
|
echo $(date) >> ~/kill.log
|
2022-04-09 07:37:18 -04:00
|
|
|
else
|
|
|
|
# Server is still running, reset the crash loop detector
|
|
|
|
rm ~/server/server_stops.log
|
2020-04-16 15:08:07 -04:00
|
|
|
fi
|
|
|
|
done
|