[object Object]

← back to Carnegie Reprice

supervisor: use nohup not setsid (setsid absent on macOS); auto-restart shard workers until ledger complete

fbe7867ae3e3ab2e654b2bcc2e83f6e914ae0389 · 2026-08-18 13:31:48 -0700 · steve

Files touched

Diff

commit fbe7867ae3e3ab2e654b2bcc2e83f6e914ae0389
Author: steve <steve@designerwallcoverings.com>
Date:   Tue Aug 18 13:31:48 2026 -0700

    supervisor: use nohup not setsid (setsid absent on macOS); auto-restart shard workers until ledger complete
---
 supervise.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/supervise.sh b/supervise.sh
new file mode 100644
index 0000000..b7093a6
--- /dev/null
+++ b/supervise.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# supervise.sh — keep the sharded Carnegie rollout workers alive until the ledger is complete.
+# Fully detached; auto-restarts a shard worker if it dies. Stops when 0 SKUs remain or HALT flag set.
+cd "$(dirname "$0")" || exit 1
+SHARDS=2
+NODE=$(command -v node)
+log(){ echo "[$(date -u +%H:%M:%S)] $*" >> supervise.log; }
+
+log "supervisor start (pid $$), $SHARDS shards"
+while true; do
+  if [ -f rebuild-HALTED.flag ]; then log "HALT flag present — supervisor exiting"; exit 0; fi
+  remaining=$("$NODE" rebuild-line.mjs --status 2>/dev/null | head -1 | sed -E 's/.* ([0-9]+) remaining.*/\1/')
+  if [ "$remaining" = "0" ]; then log "0 remaining — rollout complete, supervisor exiting"; exit 0; fi
+
+  for n in $(seq 1 $SHARDS); do
+    pidfile="worker-$n.pid"
+    alive=0
+    if [ -f "$pidfile" ] && kill -0 "$(cat "$pidfile")" 2>/dev/null; then alive=1; fi
+    if [ $alive -eq 0 ]; then
+      nohup "$NODE" rebuild-line.mjs --shard "$n/$SHARDS" >> "rebuild-shard-$n.log" 2>&1 &
+      echo $! > "$pidfile"
+      log "started shard $n/$SHARDS pid $! (remaining $remaining)"
+      sleep 3
+    fi
+  done
+  sleep 30
+done

← 118abdc auto-data-snapshot: 2026-08-18T13:28:17 (1 data files) — reb  ·  back to Carnegie Reprice  ·  gitignore ledger/logs — prevent any git checkout from trunca d53b331 →