diff --git a/src/gateway/process.ts b/src/gateway/process.ts index 571719e3b..238c2b267 100644 --- a/src/gateway/process.ts +++ b/src/gateway/process.ts @@ -19,6 +19,8 @@ export async function findExistingMoltbotProcess(sandbox: Sandbox): Promise /dev/tcp/localhost/${MOLTBOT_PORT}' 2>/dev/null && echo 'open' || echo 'closed'`, + ); + if (portCheck.stdout?.trim() === 'open') { + console.log(`Port ${MOLTBOT_PORT} already open — gateway running but undetected, skipping spawn`); + const procs = await sandbox.listProcesses(); + const any = procs.find((p) => p.status === 'running' || p.status === 'starting'); + if (any) return any; + } + } catch { + // Port probe failed — proceed to start normally + } + // Start a new OpenClaw gateway console.log('Starting new OpenClaw gateway...'); const envVars = buildEnvVars(env);