Skip to content

Commit cde4397

Browse files
author
Baudbot
committed
fix: kill orphaned start-bridge.sh supervisors on restart
Prevents port 7890 conflicts caused by stale start-bridge.sh processes surviving control-agent restarts. The issue occurred when: 1. Manual bridge restarts left orphaned start-bridge.sh supervisors running 2. 'baudbot restart' would start a new tmux-managed bridge 3. Both supervisors competed for port 7890 → EADDRINUSE errors This fix adds explicit cleanup of start-bridge.sh processes before launching the new tmux-managed bridge. Resolves recurrent bridge startup failures after manual interventions.
1 parent ff13dd5 commit cde4397

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

pi/skills/control-agent/startup-pi.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ mkdir -p "$BRIDGE_LOG_DIR"
9494
# and any leftover old-style PID-file supervisor.
9595
echo "Cleaning up old bridge..."
9696

97+
# Kill any standalone start-bridge.sh supervisors (from manual restarts or
98+
# deployments before tmux-managed bridge was introduced). These can survive
99+
# control-agent restarts and cause port conflicts with the new bridge.
100+
START_BRIDGE_PIDS=$(pgrep -f "start-bridge\.sh" 2>/dev/null || true)
101+
if [ -n "$START_BRIDGE_PIDS" ]; then
102+
echo "Killing standalone start-bridge.sh supervisors: $START_BRIDGE_PIDS"
103+
echo "$START_BRIDGE_PIDS" | xargs kill 2>/dev/null || true
104+
sleep 1
105+
# Force-kill if still alive
106+
START_BRIDGE_PIDS=$(pgrep -f "start-bridge\.sh" 2>/dev/null || true)
107+
if [ -n "$START_BRIDGE_PIDS" ]; then
108+
echo "$START_BRIDGE_PIDS" | xargs kill -9 2>/dev/null || true
109+
fi
110+
fi
111+
97112
# Kill ALL tmux sessions named slack-bridge. Using list-sessions + filter
98113
# instead of kill-session -t handles edge cases where multiple sessions
99114
# somehow got the same name (e.g., from racing startups or orphaned sessions).

0 commit comments

Comments
 (0)