[object Object]

← back to Animals

fix: animals-hawk pm2 path portable across Mac1/Mac2

04b9602eaa4c5c5656942b34dedd026a716c3d6a · 2026-05-10 07:08:46 -0700 · Steve

Hardcoded /opt/homebrew/bin/pm2 fails on Mac2 where pm2 is at ~/.npm-global/bin/pm2 — Mac2 was failing every 30m health-check, "/opt/homebrew/bin/pm2: No such file or directory" log line × hours.
Now picks first available: ~/.npm-global/bin/pm2 → /opt/homebrew/bin/pm2 → command -v pm2.

Caught by yolo-loop tick 10 reading hawk.log error pattern.

Files touched

Diff

commit 04b9602eaa4c5c5656942b34dedd026a716c3d6a
Author: Steve <steve@designerwallcoverings.com>
Date:   Sun May 10 07:08:46 2026 -0700

    fix: animals-hawk pm2 path portable across Mac1/Mac2
    
    Hardcoded /opt/homebrew/bin/pm2 fails on Mac2 where pm2 is at ~/.npm-global/bin/pm2 — Mac2 was failing every 30m health-check, "/opt/homebrew/bin/pm2: No such file or directory" log line × hours.
    Now picks first available: ~/.npm-global/bin/pm2 → /opt/homebrew/bin/pm2 → command -v pm2.
    
    Caught by yolo-loop tick 10 reading hawk.log error pattern.
---
 src/scripts/hawk-local.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/scripts/hawk-local.sh b/src/scripts/hawk-local.sh
index 16eb01f..84ddfe7 100755
--- a/src/scripts/hawk-local.sh
+++ b/src/scripts/hawk-local.sh
@@ -5,13 +5,18 @@
 set -u
 log() { echo "$(date -u +%FT%TZ) animals-hawk $*" >> /Users/stevestudio2/Projects/animals/logs/hawk.log; }
 
+# pm2 location varies (Homebrew on Mac1, npm-global on Mac2) — pick whichever exists.
+PM2_BIN="${HOME}/.npm-global/bin/pm2"
+[ -x "$PM2_BIN" ] || PM2_BIN=/opt/homebrew/bin/pm2
+[ -x "$PM2_BIN" ] || PM2_BIN=$(command -v pm2 || echo pm2)
+
 check() {
   local name=$1 port=$2
   if curl -fsS --max-time 5 "http://127.0.0.1:${port}/healthz" >/dev/null 2>&1; then
     log "OK ${name}"
   else
     log "DOWN ${name} — restarting via pm2"
-    /opt/homebrew/bin/pm2 restart "${name}" >> /Users/stevestudio2/Projects/animals/logs/hawk.log 2>&1
+    "$PM2_BIN" restart "${name}" >> /Users/stevestudio2/Projects/animals/logs/hawk.log 2>&1
   fi
 }
 

← 8a2e6ac Revert "[morning-review] animals: gate layoutModernClinic ve  ·  back to Animals  ·  animals-hawk: skip services not registered in pm2 instead of e299593 →