fix(bash): Exit simple-restarter script if shutdown is requested (#22617)

This commit is contained in:
NoxMax
2025-08-06 00:48:48 -06:00
committed by GitHub
parent 5717cd358c
commit c7351be94a

View File

@@ -66,7 +66,7 @@ while true; do
echo "$(basename "$BINARY") terminated after $DIFFERENCE seconds, restart count: $_restart_count"
# Crash loop detection
if [ $DIFFERENCE -lt 10 ]; then
if [ "$DIFFERENCE" -lt 10 ]; then
# Increment instant crash count if runtime is lower than 10 seconds
((_instant_crash_count++))
echo "Warning: Quick restart detected ($DIFFERENCE seconds) - instant crash count: $_instant_crash_count"
@@ -76,11 +76,17 @@ while true; do
fi
# Prevent infinite crash loops
if [ $_instant_crash_count -gt 5 ]; then
if [ "$_instant_crash_count" -gt 5 ]; then
echo "Error: $(basename "$BINARY") restarter exited. Infinite crash loop prevented (6 crashes in under 10 seconds each)"
echo "Please check your system configuration and logs"
exit 1
fi
# Exit cleanly if shutdown was requested by command or SIGINT (exit code 0)
if [ "$_exit_code" -eq 0 ]; then
echo "$(basename "$BINARY") shutdown safely"
exit 0
fi
echo "$(basename "$BINARY") will restart in 3 seconds..."
sleep 3