mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 19:01:11 +00:00
refactor(restart): extract stale pid cleanup and supervisor markers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { hasSupervisorHint } from "./supervisor-markers.js";
|
||||
|
||||
type RespawnMode = "spawned" | "supervised" | "disabled" | "failed";
|
||||
|
||||
@@ -8,24 +9,6 @@ export type GatewayRespawnResult = {
|
||||
detail?: string;
|
||||
};
|
||||
|
||||
const SUPERVISOR_HINT_ENV_VARS = [
|
||||
// macOS launchd — native env vars (may be set by launchd itself)
|
||||
"LAUNCH_JOB_LABEL",
|
||||
"LAUNCH_JOB_NAME",
|
||||
// macOS launchd — OpenClaw's own plist generator sets these via
|
||||
// buildServiceEnvironment() in service-env.ts. launchd does NOT
|
||||
// automatically inject LAUNCH_JOB_LABEL into the child environment,
|
||||
// so OPENCLAW_LAUNCHD_LABEL is the reliable supervised-mode signal.
|
||||
"OPENCLAW_LAUNCHD_LABEL",
|
||||
// Linux systemd
|
||||
"INVOCATION_ID",
|
||||
"SYSTEMD_EXEC_PID",
|
||||
"JOURNAL_STREAM",
|
||||
"OPENCLAW_SYSTEMD_UNIT",
|
||||
// Generic service marker (set by both launchd and systemd plist/unit generators)
|
||||
"OPENCLAW_SERVICE_MARKER",
|
||||
];
|
||||
|
||||
function isTruthy(value: string | undefined): boolean {
|
||||
if (!value) {
|
||||
return false;
|
||||
@@ -35,10 +18,7 @@ function isTruthy(value: string | undefined): boolean {
|
||||
}
|
||||
|
||||
function isLikelySupervisedProcess(env: NodeJS.ProcessEnv = process.env): boolean {
|
||||
return SUPERVISOR_HINT_ENV_VARS.some((key) => {
|
||||
const value = env[key];
|
||||
return typeof value === "string" && value.trim().length > 0;
|
||||
});
|
||||
return hasSupervisorHint(env);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user