From e366349730de55f143860fde133160f009ae3390 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 19:38:48 +0800 Subject: [PATCH] test(deadcode): reuse gateway restart intent writer --- scripts/bench-gateway-restart.ts | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/scripts/bench-gateway-restart.ts b/scripts/bench-gateway-restart.ts index ace8e1988099..b1da575bca7d 100644 --- a/scripts/bench-gateway-restart.ts +++ b/scripts/bench-gateway-restart.ts @@ -6,6 +6,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { performance } from "node:perf_hooks"; import { pathToFileURL } from "node:url"; +import { writeGatewayRestartIntentSync } from "../src/infra/restart.js"; import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts"; import { delay, stopChild, type StopChildResult } from "./lib/gateway-bench-child.ts"; import { @@ -177,7 +178,6 @@ const DEFAULT_RESTARTS = 5; const DEFAULT_TIMEOUT_MS = 30_000; const DEFAULT_POST_READY_DELAY_MS = 250; const DEFAULT_ENTRY = "dist/entry.js"; -const RESTART_INTENT_FILENAME = "gateway-restart-intent.json"; const BOOLEAN_FLAGS = new Set(["--allow-failures", "--help", "-h", "--json"]); const VALUE_FLAGS = new Set([ "--case", @@ -833,27 +833,7 @@ function sanitizedEnv( } function writeRestartIntent(env: NodeJS.ProcessEnv, targetPid: number, reason: string): boolean { - const stateDir = env.OPENCLAW_STATE_DIR; - if (!stateDir) { - return false; - } - try { - mkdirSync(stateDir, { recursive: true }); - const intentPath = path.join(stateDir, RESTART_INTENT_FILENAME); - writeFileSync( - intentPath, - `${JSON.stringify({ - kind: "gateway-restart", - pid: targetPid, - createdAt: Date.now(), - reason, - })}\n`, - { mode: 0o600 }, - ); - return true; - } catch { - return false; - } + return writeGatewayRestartIntentSync({ env, reason, targetPid }); } function readProcessFdCount(pid: number | undefined): number | null {