From 3f8cf9daf44907db4e63cd4e40c01e5de4830b9a Mon Sep 17 00:00:00 2001 From: Artur Do Lago Date: Mon, 12 Jan 2026 22:04:14 +0100 Subject: [PATCH] fix: kill any daemon that started during build Before starting daemon, now: 1. Calls daemon-stop command to cleanly stop any running daemon 2. Force kills any process on the daemon port as final measure This handles cases where a daemon auto-starts during the build process --- scripts/reload.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/reload.sh b/scripts/reload.sh index bfb8583771..98d953cf75 100755 --- a/scripts/reload.sh +++ b/scripts/reload.sh @@ -333,6 +333,19 @@ fi # Step 5: Start daemon if ! $NO_DAEMON; then + # Kill any daemon that may have started during build + log "Ensuring no daemon is running..." + "$BINARY_DST" daemon-stop 2>/dev/null || true + sleep 1 + + # Kill by port as final measure + port_pid=$(lsof -ti:$DAEMON_PORT 2>/dev/null || true) + if [[ -n "$port_pid" ]]; then + kill -9 $port_pid 2>/dev/null || true + ok "Killed process on port $DAEMON_PORT" + sleep 1 + fi + log "Starting daemon..." nohup "$BINARY_DST" daemon --hostname "$DAEMON_HOST" --port "$DAEMON_PORT" --gateway > /tmp/agent-core-daemon.log 2>&1 & DAEMON_PID=$!