mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:17:26 +00:00
refactor(wizard): dedupe gateway health check
This commit is contained in:
@@ -45,6 +45,44 @@ import { setupSkills } from "./onboard-skills.js";
|
|||||||
|
|
||||||
type ConfigureSectionChoice = WizardSection | "__continue";
|
type ConfigureSectionChoice = WizardSection | "__continue";
|
||||||
|
|
||||||
|
async function runGatewayHealthCheck(params: {
|
||||||
|
cfg: OpenClawConfig;
|
||||||
|
runtime: RuntimeEnv;
|
||||||
|
port: number;
|
||||||
|
}): Promise<void> {
|
||||||
|
const localLinks = resolveControlUiLinks({
|
||||||
|
bind: params.cfg.gateway?.bind ?? "loopback",
|
||||||
|
port: params.port,
|
||||||
|
customBindHost: params.cfg.gateway?.customBindHost,
|
||||||
|
basePath: undefined,
|
||||||
|
});
|
||||||
|
const remoteUrl = params.cfg.gateway?.remote?.url?.trim();
|
||||||
|
const wsUrl = params.cfg.gateway?.mode === "remote" && remoteUrl ? remoteUrl : localLinks.wsUrl;
|
||||||
|
const token = params.cfg.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||||
|
const password = params.cfg.gateway?.auth?.password ?? process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||||
|
|
||||||
|
await waitForGatewayReachable({
|
||||||
|
url: wsUrl,
|
||||||
|
token,
|
||||||
|
password,
|
||||||
|
deadlineMs: 15_000,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await healthCommand({ json: false, timeoutMs: 10_000 }, params.runtime);
|
||||||
|
} catch (err) {
|
||||||
|
params.runtime.error(formatHealthCheckFailure(err));
|
||||||
|
note(
|
||||||
|
[
|
||||||
|
"Docs:",
|
||||||
|
"https://docs.openclaw.ai/gateway/health",
|
||||||
|
"https://docs.openclaw.ai/gateway/troubleshooting",
|
||||||
|
].join("\n"),
|
||||||
|
"Health check help",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function promptConfigureSection(
|
async function promptConfigureSection(
|
||||||
runtime: RuntimeEnv,
|
runtime: RuntimeEnv,
|
||||||
hasSelection: boolean,
|
hasSelection: boolean,
|
||||||
@@ -368,37 +406,7 @@ export async function runConfigureWizard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selected.includes("health")) {
|
if (selected.includes("health")) {
|
||||||
const localLinks = resolveControlUiLinks({
|
await runGatewayHealthCheck({ cfg: nextConfig, runtime, port: gatewayPort });
|
||||||
bind: nextConfig.gateway?.bind ?? "loopback",
|
|
||||||
port: gatewayPort,
|
|
||||||
customBindHost: nextConfig.gateway?.customBindHost,
|
|
||||||
basePath: undefined,
|
|
||||||
});
|
|
||||||
const remoteUrl = nextConfig.gateway?.remote?.url?.trim();
|
|
||||||
const wsUrl =
|
|
||||||
nextConfig.gateway?.mode === "remote" && remoteUrl ? remoteUrl : localLinks.wsUrl;
|
|
||||||
const token = nextConfig.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN;
|
|
||||||
const password =
|
|
||||||
nextConfig.gateway?.auth?.password ?? process.env.OPENCLAW_GATEWAY_PASSWORD;
|
|
||||||
await waitForGatewayReachable({
|
|
||||||
url: wsUrl,
|
|
||||||
token,
|
|
||||||
password,
|
|
||||||
deadlineMs: 15_000,
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await healthCommand({ json: false, timeoutMs: 10_000 }, runtime);
|
|
||||||
} catch (err) {
|
|
||||||
runtime.error(formatHealthCheckFailure(err));
|
|
||||||
note(
|
|
||||||
[
|
|
||||||
"Docs:",
|
|
||||||
"https://docs.openclaw.ai/gateway/health",
|
|
||||||
"https://docs.openclaw.ai/gateway/troubleshooting",
|
|
||||||
].join("\n"),
|
|
||||||
"Health check help",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let ranSection = false;
|
let ranSection = false;
|
||||||
@@ -495,37 +503,7 @@ export async function runConfigureWizard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (choice === "health") {
|
if (choice === "health") {
|
||||||
const localLinks = resolveControlUiLinks({
|
await runGatewayHealthCheck({ cfg: nextConfig, runtime, port: gatewayPort });
|
||||||
bind: nextConfig.gateway?.bind ?? "loopback",
|
|
||||||
port: gatewayPort,
|
|
||||||
customBindHost: nextConfig.gateway?.customBindHost,
|
|
||||||
basePath: undefined,
|
|
||||||
});
|
|
||||||
const remoteUrl = nextConfig.gateway?.remote?.url?.trim();
|
|
||||||
const wsUrl =
|
|
||||||
nextConfig.gateway?.mode === "remote" && remoteUrl ? remoteUrl : localLinks.wsUrl;
|
|
||||||
const token = nextConfig.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN;
|
|
||||||
const password =
|
|
||||||
nextConfig.gateway?.auth?.password ?? process.env.OPENCLAW_GATEWAY_PASSWORD;
|
|
||||||
await waitForGatewayReachable({
|
|
||||||
url: wsUrl,
|
|
||||||
token,
|
|
||||||
password,
|
|
||||||
deadlineMs: 15_000,
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await healthCommand({ json: false, timeoutMs: 10_000 }, runtime);
|
|
||||||
} catch (err) {
|
|
||||||
runtime.error(formatHealthCheckFailure(err));
|
|
||||||
note(
|
|
||||||
[
|
|
||||||
"Docs:",
|
|
||||||
"https://docs.openclaw.ai/gateway/health",
|
|
||||||
"https://docs.openclaw.ai/gateway/troubleshooting",
|
|
||||||
].join("\n"),
|
|
||||||
"Health check help",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user