



























@@ -847,38 +847,46 @@ async function startLocalSutDaemon(params: {
847847const requestLog = path.join(params.outputDir, "mock-openai-requests.ndjson");
848848const mockLog = path.join(params.outputDir, "mock-openai.log");
849849const gatewayLog = path.join(params.outputDir, "gateway.log");
850-const mockPid = spawnDaemon({
851-command: "node",
852-args: ["scripts/e2e/mock-openai-server.mjs"],
853-cwd: params.repoRoot,
854-env: mockServerEnv({ ...params, requestLog }),
855-logPath: mockLog,
856-});
857-if (!mockPid) {
858-throw new Error("mock-openai did not start.");
859-}
860-await waitForLog(mockLog, /mock-openai listening/u, "mock-openai", 10_000);
850+ let mockPid: number | undefined;
851+ let gatewayPid: number | undefined;
852+try {
853+mockPid = spawnDaemon({
854+command: "node",
855+args: ["scripts/e2e/mock-openai-server.mjs"],
856+cwd: params.repoRoot,
857+env: mockServerEnv({ ...params, requestLog }),
858+logPath: mockLog,
859+});
860+if (!mockPid) {
861+throw new Error("mock-openai did not start.");
862+}
863+await waitForLog(mockLog, /mock-openai listening/u, "mock-openai", 10_000);
861864862-const gatewayPid = spawnDaemon({
863-command: "pnpm",
864-args: ["openclaw", "gateway", "--port", String(params.gatewayPort)],
865-cwd: params.repoRoot,
866-env: gatewayEnv({ ...config, sutToken: params.sutToken }),
867-logPath: gatewayLog,
868-});
869-if (!gatewayPid) {
870-throw new Error("gateway did not start.");
865+gatewayPid = spawnDaemon({
866+command: "pnpm",
867+args: ["openclaw", "gateway", "--port", String(params.gatewayPort)],
868+cwd: params.repoRoot,
869+env: gatewayEnv({ ...config, sutToken: params.sutToken }),
870+logPath: gatewayLog,
871+});
872+if (!gatewayPid) {
873+throw new Error("gateway did not start.");
874+}
875+await waitForLog(gatewayLog, /\[gateway\] ready/u, "gateway", 60_000);
876+return {
877+ ...config,
878+ drained,
879+ gatewayLog,
880+ gatewayPid,
881+ mockLog,
882+ mockPid,
883+ requestLog,
884+};
885+} catch (error) {
886+killPidTree(gatewayPid);
887+killPidTree(mockPid);
888+throw error;
871889}
872-await waitForLog(gatewayLog, /\[gateway\] ready/u, "gateway", 60_000);
873-return {
874- ...config,
875- drained,
876- gatewayLog,
877- gatewayPid,
878- mockLog,
879- mockPid,
880- requestLog,
881-};
882890}
883891884892function extractLeaseId(output: string) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。