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
This commit is contained in:
Artur Do Lago
2026-01-12 22:04:14 +01:00
parent 8890db07f7
commit 3f8cf9daf4
+13
View File
@@ -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=$!