mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:24:31 +00:00
refactor: extract gateway port diagnostics helper
This commit is contained in:
@@ -242,6 +242,22 @@ export async function waitForGatewayHealthyListener(params: {
|
|||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderPortUsageDiagnostics(snapshot: GatewayPortHealthSnapshot): string[] {
|
||||||
|
const lines: string[] = [];
|
||||||
|
|
||||||
|
if (snapshot.portUsage.status === "busy") {
|
||||||
|
lines.push(...formatPortDiagnostics(snapshot.portUsage));
|
||||||
|
} else {
|
||||||
|
lines.push(`Gateway port ${snapshot.portUsage.port} status: ${snapshot.portUsage.status}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snapshot.portUsage.errors?.length) {
|
||||||
|
lines.push(`Port diagnostics errors: ${snapshot.portUsage.errors.join("; ")}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
export function renderRestartDiagnostics(snapshot: GatewayRestartSnapshot): string[] {
|
export function renderRestartDiagnostics(snapshot: GatewayRestartSnapshot): string[] {
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
const runtimeSummary = [
|
const runtimeSummary = [
|
||||||
@@ -257,33 +273,13 @@ export function renderRestartDiagnostics(snapshot: GatewayRestartSnapshot): stri
|
|||||||
lines.push(`Service runtime: ${runtimeSummary}`);
|
lines.push(`Service runtime: ${runtimeSummary}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.portUsage.status === "busy") {
|
lines.push(...renderPortUsageDiagnostics(snapshot));
|
||||||
lines.push(...formatPortDiagnostics(snapshot.portUsage));
|
|
||||||
} else {
|
|
||||||
lines.push(`Gateway port ${snapshot.portUsage.port} status: ${snapshot.portUsage.status}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snapshot.portUsage.errors?.length) {
|
|
||||||
lines.push(`Port diagnostics errors: ${snapshot.portUsage.errors.join("; ")}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderGatewayPortHealthDiagnostics(snapshot: GatewayPortHealthSnapshot): string[] {
|
export function renderGatewayPortHealthDiagnostics(snapshot: GatewayPortHealthSnapshot): string[] {
|
||||||
const lines: string[] = [];
|
return renderPortUsageDiagnostics(snapshot);
|
||||||
|
|
||||||
if (snapshot.portUsage.status === "busy") {
|
|
||||||
lines.push(...formatPortDiagnostics(snapshot.portUsage));
|
|
||||||
} else {
|
|
||||||
lines.push(`Gateway port ${snapshot.portUsage.port} status: ${snapshot.portUsage.status}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snapshot.portUsage.errors?.length) {
|
|
||||||
lines.push(`Port diagnostics errors: ${snapshot.portUsage.errors.join("; ")}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function terminateStaleGatewayPids(pids: number[]): Promise<number[]> {
|
export async function terminateStaleGatewayPids(pids: number[]): Promise<number[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user