mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
refactor(daemon): share runtime status formatter
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
resolveGatewayWindowsTaskName,
|
||||
} from "../daemon/constants.js";
|
||||
import { resolveGatewayLogPaths } from "../daemon/launchd.js";
|
||||
import { formatRuntimeStatus } from "../daemon/runtime-format.js";
|
||||
import {
|
||||
isSystemdUnavailableDetail,
|
||||
renderSystemdUnavailableHints,
|
||||
@@ -21,36 +22,7 @@ type RuntimeHintOptions = {
|
||||
export function formatGatewayRuntimeSummary(
|
||||
runtime: GatewayServiceRuntime | undefined,
|
||||
): string | null {
|
||||
if (!runtime) {
|
||||
return null;
|
||||
}
|
||||
const status = runtime.status ?? "unknown";
|
||||
const details: string[] = [];
|
||||
if (runtime.pid) {
|
||||
details.push(`pid ${runtime.pid}`);
|
||||
}
|
||||
if (runtime.state && runtime.state.toLowerCase() !== status) {
|
||||
details.push(`state ${runtime.state}`);
|
||||
}
|
||||
if (runtime.subState) {
|
||||
details.push(`sub ${runtime.subState}`);
|
||||
}
|
||||
if (runtime.lastExitStatus !== undefined) {
|
||||
details.push(`last exit ${runtime.lastExitStatus}`);
|
||||
}
|
||||
if (runtime.lastExitReason) {
|
||||
details.push(`reason ${runtime.lastExitReason}`);
|
||||
}
|
||||
if (runtime.lastRunResult) {
|
||||
details.push(`last run ${runtime.lastRunResult}`);
|
||||
}
|
||||
if (runtime.lastRunTime) {
|
||||
details.push(`last run time ${runtime.lastRunTime}`);
|
||||
}
|
||||
if (runtime.detail) {
|
||||
details.push(runtime.detail);
|
||||
}
|
||||
return details.length > 0 ? `${status} (${details.join(", ")})` : status;
|
||||
return formatRuntimeStatus(runtime);
|
||||
}
|
||||
|
||||
export function buildGatewayRuntimeHints(
|
||||
|
||||
Reference in New Issue
Block a user