From 41fec8da577adb21440400a396c05bfbb0dfadd0 Mon Sep 17 00:00:00 2001 From: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Date: Sun, 28 Jun 2026 14:13:32 -0400 Subject: [PATCH] fix(dev): fail fast on occupied relay ports Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> --- Justfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Justfile b/Justfile index 7b814e5140..bc427e47ff 100644 --- a/Justfile +++ b/Justfile @@ -297,9 +297,30 @@ dev *ARGS: bootstrap _ensure-sidecar-stubs _ensure-migrations #!/usr/bin/env bash set -euo pipefail export PATH="{{justfile_directory()}}/bin:$PATH" + bind_addr="${BUZZ_BIND_ADDR:-0.0.0.0:3000}" + relay_port="${bind_addr##*:}"; [[ -n "$relay_port" ]] || relay_port=3000 + health_port="${BUZZ_HEALTH_PORT:-8080}" + metrics_port="${BUZZ_METRICS_PORT:-9102}" + if command -v lsof >/dev/null 2>&1; then + for spec in "relay:$relay_port" "health:$health_port" "metrics:$metrics_port"; do + name="${spec%%:*}"; port="${spec##*:}" + if lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1; then + echo "Error: $name port $port is already in use; refusing to launch desktop against a stale relay." >&2 + lsof -nP -iTCP:"$port" -sTCP:LISTEN >&2 || true + echo "Stop the process above (often a stale buzz-relay) and rerun: just dev" >&2 + exit 1 + fi + done + fi cargo build -p buzz-acp -p buzz-agent -p buzz-dev-mcp -p buzz-cli -p git-credential-nostr -p buzz-relay ./target/debug/buzz-relay & RELAY_PID=$! + sleep 1 + if ! kill -0 "$RELAY_PID" 2>/dev/null; then + echo "Error: buzz-relay exited during startup; refusing to launch desktop against a stale relay." >&2 + wait "$RELAY_PID" || true + exit 1 + fi cleanup() { [[ -n "${INSTANCE_ID:-}" ]] && ../scripts/cleanup-instance-agents.sh "$INSTANCE_ID" || true kill "$RELAY_PID" 2>/dev/null || true