Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

fix(crs): auto-detect CRS host port in priority daemon health-gate (#588)

Aurora Capital4a5840d8f423
diff --git a/claude-ops/scripts/account-rotation/crs-priority-daemon.mjs b/claude-ops/scripts/account-rotation/crs-priority-daemon.mjs
index e693ea53..9aa71d77 100755
--- a/claude-ops/scripts/account-rotation/crs-priority-daemon.mjs
+++ b/claude-ops/scripts/account-rotation/crs-priority-daemon.mjs
@@ -72,7 +72,10 @@ const cfg = loadConfig();
const C = cfg.crs || {};
const num = (v, d) => (v === undefined || v === null || v === '' || Number.isNaN(+v) ? d : +v);
-const BASE = process.env.CRS_BASE || C.baseUrl || 'http://127.0.0.1:3000';
+// CRS_BASE is normally exported by the .sh wrapper after it probes the live host
+// port (:3005 or :3000). config.json "crs".baseUrl overrides next; the literal is
+// only a last resort and matches this fleet's published port (...:3005->3000).
+const BASE = process.env.CRS_BASE || C.baseUrl || 'http://127.0.0.1:3005';
const ADMIN_USER = process.env.CRS_ADMIN_USER || C.adminUser || 'cradmin';
const OFF_5H = num(process.env.CRS_OFF_5H ?? C.off5h, 90);
const OFF_7D = num(process.env.CRS_OFF_7D ?? C.off7d, 95);
diff --git a/claude-ops/scripts/account-rotation/crs-priority-daemon.sh b/claude-ops/scripts/account-rotation/crs-priority-daemon.sh
index 279c60b4..6cd38160 100755
--- a/claude-ops/scripts/account-rotation/crs-priority-daemon.sh
+++ b/claude-ops/scripts/account-rotation/crs-priority-daemon.sh
@@ -11,7 +11,13 @@ DATA_DIR="${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketpla
LOG_DIR="$DATA_DIR/logs"
LOG="$LOG_DIR/crs-priority.log"
NODE="${CRS_NODE_BIN:-$(command -v node || echo /opt/homebrew/bin/node)}"
-BASE="${CRS_BASE:-http://127.0.0.1:3000}"
+# CRS's container port (:3000) is published on the host at either :3000 or :3005
+# depending on the deploy (this fleet maps ...:3005->3000). Honor an explicit
+# CRS_BASE; otherwise probe the known candidates and pick the first that answers
+# /health, so a host port-mapping change can't silently freeze the daemon (it
+# used to default to :3000, get 000 against a :3005-mapped relay, and exit 0
+# every tick — priority scheduling dead until someone noticed).
+BASE="${CRS_BASE:-}"
mkdir -p "$LOG_DIR"
@@ -27,7 +33,16 @@ fi
trap 'rmdir "$LOCK" 2>/dev/null' EXIT
# Skip silently if CRS isn't reachable (don't spam the log while the relay is down).
-curl -sf -o /dev/null --max-time 5 "$BASE/health" || exit 0
+# Auto-detect the host port unless CRS_BASE was set explicitly.
+if [ -n "$BASE" ]; then
+ curl -sf -o /dev/null --max-time 5 "$BASE/health" || exit 0
+else
+ for cand in http://127.0.0.1:3005 http://127.0.0.1:3000; do
+ if curl -sf -o /dev/null --max-time 5 "$cand/health"; then BASE="$cand"; break; fi
+ done
+ [ -n "$BASE" ] || exit 0 # relay unreachable on every candidate
+fi
+export CRS_BASE="$BASE" # hand the resolved base to the node tick
# Rotate log past ~2MB.
if [ -f "$LOG" ] && [ "$(wc -c < "$LOG" 2>/dev/null || echo 0)" -gt 2097152 ]; then