Bound the watchdogs' docker calls — a hung daemon is what they exist to catch

This commit is contained in:
Gmer4Lfe
2026-08-24 18:39:59 -04:00
parent 84946ed0c6
commit 049f633667
4 changed files with 14 additions and 7 deletions
+5 -2
View File
@@ -210,9 +210,12 @@ _rw_trap_restart_stopped() {
[[ ${#_RW_TRAP_STOPPED[@]} -eq 0 ]] && return
for c in "${_RW_TRAP_STOPPED[@]}"; do
[[ -z "$c" ]] && continue
if docker inspect "$c" >/dev/null 2>&1; then
# Bounded, because this runs from the EXIT trap. An unbounded docker call here means a
# hung daemon stops the script exiting at all — it keeps its lock, and the containers
# this trap exists to bring back stay down.
if timeout "$DOCKER_TIMEOUT" docker inspect "$c" >/dev/null 2>&1; then
warn "Exit trap: restarting $c (stopped but state not persisted)"
docker start "$c" >/dev/null 2>&1 || warn " Failed to restart $c"
timeout "$DOCKER_TIMEOUT" docker start "$c" >/dev/null 2>&1 || warn " Failed to restart $c"
fi
done
}