diff --git a/dev2/c0mpute-gateway/c0mpute-gateway-watchdog b/dev2/c0mpute-gateway/c0mpute-gateway-watchdog index 7ab52f4..056b6f6 100755 --- a/dev2/c0mpute-gateway/c0mpute-gateway-watchdog +++ b/dev2/c0mpute-gateway/c0mpute-gateway-watchdog @@ -22,6 +22,20 @@ for wait in 0 1 1 2 3 5; do ok && exit 0 done +# A worker that started recently is still coming up: since 0.3.136 it brings its +# apps up before it opens :7777, which took 3.5 min on 2026-11-30. Restarting it +# inside that window only starts the wait again (it looped every 2 min for 15 min +# and took every Moshpit name on c0mpute down). Leave it alone for GRACE seconds. +GRACE="${C0MPUTE_GATEWAY_GRACE:-480}" +if systemctl is-active --quiet "$UNIT"; then + since=$(systemctl show -p ActiveEnterTimestampMonotonic --value "$UNIT" 2>/dev/null || echo 0) + now=$(awk '{printf "%d", $1 * 1000000}' /proc/uptime) + if [ "${since:-0}" -gt 0 ] && [ $(( (now - since) / 1000000 )) -lt "$GRACE" ]; then + log "$URL not answering yet, but $UNIT started $(( (now - since) / 1000000 )) s ago (grace ${GRACE} s); waiting" + exit 0 + fi +fi + # Someone may be running a worker by hand on :7777 (a session relaunch). It is not # answering either, so the unit is the one to bring back. if systemctl is-active --quiet "$UNIT"; then