mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(deadcode): reuse gateway restart intent writer
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user