diff --git a/scripts/runewager_redeploy.sh b/scripts/runewager_redeploy.sh index 4cbe973..4aefd39 100755 --- a/scripts/runewager_redeploy.sh +++ b/scripts/runewager_redeploy.sh @@ -121,6 +121,17 @@ _stop_bot_service() { else warn "${BOT_SERVICE} service was not running (OK)" fi + + # Stop legacy service names so they can't restart and steal port ${BOT_PORT} + # while this redeploy is in progress. Failures are non-fatal. + local _legacy + for _legacy in "runewager-bot" "runewager_bot"; do + if [[ "$_legacy" != "$BOT_SERVICE" ]] \ + && systemctl is-active --quiet "$_legacy" 2>/dev/null; then + warn "Legacy service '${_legacy}' is running — stopping to prevent port conflict" + systemctl stop "$_legacy" 2>/dev/null || true + fi + done } # ─────────────────────────────── STEP 2: KILL PORT ─────────────────────────── @@ -260,7 +271,7 @@ _health_check() { echo "$_payload" | jq . 2>/dev/null | head -20 | sed 's/^/ /' \ || echo "$_payload" | head -20 | sed 's/^/ /' else - echo "$_payload" | head -20 | sed 's/^/ /' + printf '%s\n' "$_payload" | head -20 | sed 's/^/ /' fi return 0 fi @@ -320,7 +331,11 @@ _summary() { for svc in "$BOT_SERVICE" "rw_cpu_guard"; do local state - state=$(systemctl is-active "$svc" 2>/dev/null) || state="not-found" + # systemctl is-active exits non-zero for failed/inactive/unknown too, + # so capture the printed state string; only default to "not-found" when + # the command produces no output at all (unit truly unknown to systemd). + state=$(systemctl is-active "$svc" 2>/dev/null) + [[ -z "$state" ]] && state="not-found" if [[ "$state" == "active" ]]; then ok " ${svc}: ${state}" else diff --git a/scripts/rw_cpu_guard.sh b/scripts/rw_cpu_guard.sh index 47d405c..6ea0338 100755 --- a/scripts/rw_cpu_guard.sh +++ b/scripts/rw_cpu_guard.sh @@ -678,7 +678,7 @@ _run_forensics() { fi # ── 1-second CPU tracer (catches sub-8s spikes the guard daemon may miss) ─ - echo "timestamp,pid,ppid,cpu%,mem%,cmd" > "$trace" + echo "timestamp,pid,ppid,cpu%,mem%,args" > "$trace" ( while true; do # Use 'args' (not 'cmd') so the full command path and every argument # are captured. Fields $5..$NF are joined into one value so commands