start.sh: print warnings on unusual exit codes from the server process (#6497)

This commit is contained in:
Dylan T. 2024-11-15 21:14:21 +00:00 committed by GitHub
parent fb1213e964
commit 4b630cb726
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,6 +44,27 @@ fi
LOOPS=0
handle_exit_code() {
local exitcode=$1
if [ "$exitcode" -eq 134 ] || [ "$exitcode" -eq 139 ]; then #SIGABRT/SIGSEGV
echo ""
echo "ERROR: The server process was killed due to a critical error (code $exitcode) which could indicate a problem with PHP."
echo "Updating your PHP binary is recommended."
echo "If this keeps happening, please open a bug report."
echo ""
elif [ "$exitcode" -eq 143 ]; then #SIGKILL, maybe user intervention
echo ""
echo "WARNING: Server was forcibly killed!"
echo "If you didn't kill the server manually, this probably means the server used too much memory and was killed by the system's OOM Killer."
echo "Please ensure your system has enough available RAM."
echo ""
elif [ "$exitcode" -ne 0 ] && [ "$exitcode" -ne 137 ]; then #normal exit / SIGTERM
echo ""
echo "WARNING: Server did not shut down correctly! (code $exitcode)"
echo ""
fi
}
set +e
if [ "$DO_LOOP" == "yes" ]; then
@ -52,11 +73,15 @@ if [ "$DO_LOOP" == "yes" ]; then
echo "Restarted $LOOPS times"
fi
"$PHP_BINARY" "$POCKETMINE_FILE" "$@"
handle_exit_code $?
echo "To escape the loop, press CTRL+C now. Otherwise, wait 5 seconds for the server to restart."
echo ""
sleep 5
((LOOPS++))
done
else
exec "$PHP_BINARY" "$POCKETMINE_FILE" "$@"
"$PHP_BINARY" "$POCKETMINE_FILE" "$@"
exitcode=$?
handle_exit_code $exitcode
exit $exitcode
fi