


























@@ -6,6 +6,7 @@ import { tmpdir } from "node:os";
66import path from "node:path";
77import { performance } from "node:perf_hooks";
88import { pathToFileURL } from "node:url";
9+import { writeGatewayRestartIntentSync } from "../src/infra/restart.js";
910import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts";
1011import { delay, stopChild, type StopChildResult } from "./lib/gateway-bench-child.ts";
1112import {
@@ -177,7 +178,6 @@ const DEFAULT_RESTARTS = 5;
177178const DEFAULT_TIMEOUT_MS = 30_000;
178179const DEFAULT_POST_READY_DELAY_MS = 250;
179180const DEFAULT_ENTRY = "dist/entry.js";
180-const RESTART_INTENT_FILENAME = "gateway-restart-intent.json";
181181const BOOLEAN_FLAGS = new Set(["--allow-failures", "--help", "-h", "--json"]);
182182const VALUE_FLAGS = new Set([
183183"--case",
@@ -833,27 +833,7 @@ function sanitizedEnv(
833833}
834834835835function writeRestartIntent(env: NodeJS.ProcessEnv, targetPid: number, reason: string): boolean {
836-const stateDir = env.OPENCLAW_STATE_DIR;
837-if (!stateDir) {
838-return false;
839-}
840-try {
841-mkdirSync(stateDir, { recursive: true });
842-const intentPath = path.join(stateDir, RESTART_INTENT_FILENAME);
843-writeFileSync(
844-intentPath,
845-`${JSON.stringify({
846- kind: "gateway-restart",
847- pid: targetPid,
848- createdAt: Date.now(),
849- reason,
850- })}\n`,
851-{ mode: 0o600 },
852-);
853-return true;
854-} catch {
855-return false;
856-}
836+return writeGatewayRestartIntentSync({ env, reason, targetPid });
857837}
858838859839function readProcessFdCount(pid: number | undefined): number | null {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。