← back to Ventura Corridor
fix(ops): rewrite hawk to query pm2 status not http — only restart when status!=online; restores correct watchdog semantics modeled on sf-hawk; export PATH so node is reachable under launchd's minimal env
c5a0c97aaed6b4d777f8d85b6b1995a577face41 · 2026-05-06 12:36:59 -0700 · SteveStudio2
Files touched
Diff
commit c5a0c97aaed6b4d777f8d85b6b1995a577face41
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Wed May 6 12:36:59 2026 -0700
fix(ops): rewrite hawk to query pm2 status not http — only restart when status!=online; restores correct watchdog semantics modeled on sf-hawk; export PATH so node is reachable under launchd's minimal env
---
scripts/hawk-local.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/scripts/hawk-local.sh b/scripts/hawk-local.sh
new file mode 100755
index 0000000..0066e06
--- /dev/null
+++ b/scripts/hawk-local.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Local PM2 watchdog for ventura-corridor.
+# Runs every 30m via launchd com.steve.ventura-corridor-hawk.
+# Daemon dead → pm2 resurrect. ventura-corridor not online → pm2 restart.
+# Modeled on site-factory/scripts/hawk-local.sh.
+#
+# Why not curl-based: a naive `curl health || pm2 restart` mass-restarts on
+# any transient timeout (slow DB query, brief CPU contention). pm2 already
+# autorestarts genuinely-crashed processes; this hawk's only job is to catch
+# the "process truly hung/missing" case, which means status != online.
+
+set -uo pipefail
+
+# launchd's env is minimal — pm2 internally calls `node` so we need it on PATH
+export PATH="/Users/stevestudio2/.npm-global/bin:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin"
+
+PM2=/Users/stevestudio2/.npm-global/bin/pm2
+LOG=/Users/stevestudio2/Projects/ventura-corridor/logs/hawk.log
+TS() { date -u +%FT%TZ; }
+mkdir -p "$(dirname "$LOG")"
+
+if ! JLIST=$("$PM2" jlist 2>/dev/null); then
+ echo "[$(TS)] DAEMON DOWN — running pm2 resurrect" >> "$LOG"
+ "$PM2" resurrect >> "$LOG" 2>&1
+ exit 0
+fi
+
+STATUS=$(printf '%s' "$JLIST" \
+ | /usr/bin/python3 -c '
+import json, sys
+try:
+ procs = json.load(sys.stdin)
+except Exception:
+ sys.exit(0)
+for p in procs:
+ if p.get("name") == "ventura-corridor":
+ print(p.get("pm2_env", {}).get("status", "missing"))
+ sys.exit(0)
+print("missing")
+')
+
+if [ "$STATUS" = "online" ]; then
+ echo "[$(TS)] OK — ventura-corridor online" >> "$LOG"
+else
+ echo "[$(TS)] ventura-corridor status=$STATUS — restarting" >> "$LOG"
+ "$PM2" restart ventura-corridor >> "$LOG" 2>&1
+fi
← dbf656b iter 52: postcard preview + Lob template generator — public/
·
back to Ventura Corridor
·
iter 53: building 360° tenant roster — migration 013 adds v_ 410b896 →