← back to Wallco Ai
deploy: orphaned-entrypoint guard — warn if a pm2 process points at a file rsync --delete removed (wallco-hot-or-not incident)
c76ad294f018bd977b89840469de3b5b6b1afcfc · 2026-06-01 14:10:55 -0700 · Steve Abrams
Files touched
Diff
commit c76ad294f018bd977b89840469de3b5b6b1afcfc
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jun 1 14:10:55 2026 -0700
deploy: orphaned-entrypoint guard — warn if a pm2 process points at a file rsync --delete removed (wallco-hot-or-not incident)
---
deploy-kamatera.sh | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/deploy-kamatera.sh b/deploy-kamatera.sh
index 030dde7..5e34367 100755
--- a/deploy-kamatera.sh
+++ b/deploy-kamatera.sh
@@ -120,6 +120,34 @@ echo "[4/6] pm2 startOrReload..."
ssh "$REMOTE" "cd $REMOTE_DIR && pm2 startOrReload ecosystem.config.js --only $PM2_NAME 2>&1 | tail -10 || pm2 start server.js --name $PM2_NAME --cwd $REMOTE_DIR -- --port $PORT"
ssh "$REMOTE" "pm2 save"
+# 5b. Orphaned-entrypoint guard (added 2026-06-01 after the wallco-hot-or-not
+# incident). `rsync --delete` mirrors the repo onto prod, so deleting a file
+# from the repo deletes it from prod too. If a pm2 process still points at a
+# script file under THIS deploy dir that no longer exists, it crash-loops
+# forever (MODULE_NOT_FOUND, 1800+ restarts last time). This checks ONLY pm2
+# processes whose script path is under $REMOTE_DIR — so it never false-positives
+# on the box's other ~180 apps — and warns (non-fatal) if any references a
+# now-missing file, naming the exact fix.
+echo "[4b/6] orphaned-entrypoint guard..."
+ssh "$REMOTE" "pm2 jlist 2>/dev/null | DEPLOY_DIR='$REMOTE_DIR' python3 -c \"
+import sys, json, os
+deploy_dir = os.environ['DEPLOY_DIR'].rstrip('/') + '/'
+try: procs = json.load(sys.stdin)
+except Exception: procs = []
+bad = []
+for p in procs:
+ sp = (p.get('pm2_env', {}) or {}).get('pm_exec_path', '') or ''
+ if sp.startswith(deploy_dir) and not os.path.exists(sp):
+ bad.append((p.get('name', '?'), sp))
+if bad:
+ print(' WARNING: pm2 process(es) point at MISSING files under this deploy dir:')
+ for n, sp in bad:
+ print(' - ' + n + ' -> ' + sp + ' (will crash-loop)')
+ print(' Fix: restore the file from git, OR retire the process: pm2 delete <name> && pm2 save')
+else:
+ print(' ok - no pm2 process references a deleted file in the deploy dir')
+\""
+
# 6. Health check (wait up to 20s)
echo "[5/6] Health check → $HEALTH_URL"
for i in $(seq 1 10); do
← 624d542 SECURITY: admin-gate isLocalhost no longer trusts Host heade
·
back to Wallco Ai
·
SECURITY: fix reflected XSS in htmlHead (<head> now esc()'d c2f49d0 →