From b345af9ee39953a10b1f8ab65d2ba54fef396963 Mon Sep 17 00:00:00 2001 From: jaxperro Date: Wed, 8 Jul 2026 17:44:08 -0400 Subject: [PATCH] =?UTF-8?q?watchdog:=20GH=20Actions=20dead-man's=20switch?= =?UTF-8?q?=20=E2=80=94=20/health=20probe=20+=20Discord=20alert=20(layer?= =?UTF-8?q?=202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .github/workflows/watchdog.yml | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/watchdog.yml diff --git a/.github/workflows/watchdog.yml b/.github/workflows/watchdog.yml new file mode 100644 index 00000000..0428ee13 --- /dev/null +++ b/.github/workflows/watchdog.yml @@ -0,0 +1,35 @@ +# Dead-man's switch for the copybot worker (the notify half; the self-heal +# half is fly.toml's http /health check, which restarts a dark machine). +# GH cron is coarse (fires ~every 30-150 min in practice) — fine here: the +# failure mode this guards is MULTI-HOUR silence (the 2026-07-07 Fly trial +# expiry left the bot dark 3.5h with nothing watching). Runs on GitHub's +# infra, so it works when the Mac is asleep AND the Fly box is dead. +name: watchdog +on: + schedule: + - cron: "*/30 * * * *" + workflow_dispatch: + +jobs: + health: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: probe /health (3 tries, 60s apart) + id: probe + run: | + for i in 1 2 3; do + if curl -fsS --max-time 10 https://wwf-copybot.fly.dev/health; then + echo; echo "healthy on try $i"; exit 0 + fi + echo "try $i failed"; [ $i -lt 3 ] && sleep 60 + done + exit 1 + - name: alert Discord + if: failure() + run: | + curl -fsS -X POST -H 'Content-Type: application/json' \ + -d '{"content":"🚨 **copybot DOWN** — wwf-copybot.fly.dev/health failed 3 probes over 2 min. Check `flyctl status --app wwf-copybot` / `flyctl logs`. (Fly auto-restart should be trying; if this repeats, it is crash-looping or the account/billing broke — see 2026-07-07 trial-expiry incident.)"}' \ + "$DISCORD_WEBHOOK_URL" + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}