mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 06:32:43 +00:00
refactor(diagnostics): hot-reload stuck warning threshold
This commit is contained in:
@@ -159,6 +159,12 @@ describe("buildGatewayReloadPlan", () => {
|
|||||||
expect(plan.noopPaths).toContain("secrets.providers.default.path");
|
expect(plan.noopPaths).toContain("secrets.providers.default.path");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("treats diagnostics.stuckSessionWarnMs as no-op for gateway restart planning", () => {
|
||||||
|
const plan = buildGatewayReloadPlan(["diagnostics.stuckSessionWarnMs"]);
|
||||||
|
expect(plan.restartGateway).toBe(false);
|
||||||
|
expect(plan.noopPaths).toContain("diagnostics.stuckSessionWarnMs");
|
||||||
|
});
|
||||||
|
|
||||||
it("defaults unknown paths to restart", () => {
|
it("defaults unknown paths to restart", () => {
|
||||||
const plan = buildGatewayReloadPlan(["unknownField"]);
|
const plan = buildGatewayReloadPlan(["unknownField"]);
|
||||||
expect(plan.restartGateway).toBe(true);
|
expect(plan.restartGateway).toBe(true);
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ const MISSING_CONFIG_MAX_RETRIES = 2;
|
|||||||
const BASE_RELOAD_RULES: ReloadRule[] = [
|
const BASE_RELOAD_RULES: ReloadRule[] = [
|
||||||
{ prefix: "gateway.remote", kind: "none" },
|
{ prefix: "gateway.remote", kind: "none" },
|
||||||
{ prefix: "gateway.reload", kind: "none" },
|
{ prefix: "gateway.reload", kind: "none" },
|
||||||
|
// Stuck-session warning threshold is read by the diagnostics heartbeat loop.
|
||||||
|
{ prefix: "diagnostics.stuckSessionWarnMs", kind: "none" },
|
||||||
{ prefix: "hooks.gmail", kind: "hot", actions: ["restart-gmail-watcher"] },
|
{ prefix: "hooks.gmail", kind: "hot", actions: ["restart-gmail-watcher"] },
|
||||||
{ prefix: "hooks", kind: "hot", actions: ["reload-hooks"] },
|
{ prefix: "hooks", kind: "hot", actions: ["reload-hooks"] },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ export async function startGatewayServer(
|
|||||||
).config;
|
).config;
|
||||||
const diagnosticsEnabled = isDiagnosticsEnabled(cfgAtStart);
|
const diagnosticsEnabled = isDiagnosticsEnabled(cfgAtStart);
|
||||||
if (diagnosticsEnabled) {
|
if (diagnosticsEnabled) {
|
||||||
startDiagnosticHeartbeat(cfgAtStart);
|
startDiagnosticHeartbeat();
|
||||||
}
|
}
|
||||||
setGatewaySigusr1RestartPolicy({ allowExternal: isRestartEnabled(cfgAtStart) });
|
setGatewaySigusr1RestartPolicy({ allowExternal: isRestartEnabled(cfgAtStart) });
|
||||||
setPreRestartDeferralCheck(
|
setPreRestartDeferralCheck(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { loadConfig } from "../config/config.js";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { emitDiagnosticEvent } from "../infra/diagnostic-events.js";
|
import { emitDiagnosticEvent } from "../infra/diagnostic-events.js";
|
||||||
import {
|
import {
|
||||||
@@ -325,8 +326,16 @@ export function startDiagnosticHeartbeat(config?: OpenClawConfig) {
|
|||||||
if (heartbeatInterval) {
|
if (heartbeatInterval) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const stuckSessionWarnMs = resolveStuckSessionWarnMs(config);
|
|
||||||
heartbeatInterval = setInterval(() => {
|
heartbeatInterval = setInterval(() => {
|
||||||
|
let heartbeatConfig = config;
|
||||||
|
if (!heartbeatConfig) {
|
||||||
|
try {
|
||||||
|
heartbeatConfig = loadConfig();
|
||||||
|
} catch {
|
||||||
|
heartbeatConfig = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const stuckSessionWarnMs = resolveStuckSessionWarnMs(heartbeatConfig);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
pruneDiagnosticSessionStates(now, true);
|
pruneDiagnosticSessionStates(now, true);
|
||||||
const activeCount = Array.from(diagnosticSessionStates.values()).filter(
|
const activeCount = Array.from(diagnosticSessionStates.values()).filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user