

















@@ -25,6 +25,7 @@ const COMMAND_TIMEOUT_MS = readPositiveInt(
2525);
2626const RPC_TIMEOUT_MS = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_CALL_MS, 60000);
2727const MAX_RSS_MIB = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_MAX_RSS_MIB, 2048);
28+const DEFAULT_PORT = 19000 + Math.floor(Math.random() * 1000);
28292930let callGatewayModulePromise;
3031@@ -357,7 +358,7 @@ function startGateway(runner, port, env, logPath) {
357358const child = childProcess.spawn(command.command, command.args, {
358359 ...command.options,
359360 env,
360-detached: false,
361+detached: process.platform !== "win32",
361362});
362363fs.closeSync(log);
363364return child;
@@ -367,16 +368,26 @@ async function stopGateway(child) {
367368if (!child || child.exitCode !== null) {
368369return;
369370}
370-child.kill("SIGTERM");
371+signalGateway(child, "SIGTERM");
371372const started = Date.now();
372373while (child.exitCode === null && Date.now() - started < 10000) {
373374await delay(100);
374375}
375376if (child.exitCode === null) {
376-child.kill("SIGKILL");
377+signalGateway(child, "SIGKILL");
377378}
378379}
379380381+function signalGateway(child, signal) {
382+if (process.platform !== "win32" && typeof child.pid === "number") {
383+try {
384+process.kill(-child.pid, signal);
385+return;
386+} catch {}
387+}
388+child.kill(signal);
389+}
390+380391async function waitForGatewayReady(child, port, logPath) {
381392const started = Date.now();
382393let lastError = "";
@@ -555,7 +566,7 @@ function isNonEmptyString(value) {
555566556567async function main() {
557568const runner = resolveOpenClawRunner();
558-const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, 19173);
569+const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, DEFAULT_PORT);
559570const { root, env } = makeEnv();
560571const logPath = path.join(root, "gateway.log");
561572此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。