gateway: wire channel health monitor into startup with configurable interval

This commit is contained in:
David Szarzynski
2026-02-12 11:47:26 +07:00
committed by Peter Steinberger
parent 497e2d76ad
commit 30ee12e40a
2 changed files with 17 additions and 0 deletions

View File

@@ -312,4 +312,10 @@ export type GatewayConfig = {
trustedProxies?: string[];
/** Tool access restrictions for HTTP /tools/invoke endpoint. */
tools?: GatewayToolsConfig;
/**
* Channel health monitor interval in minutes.
* Periodically checks channel health and restarts unhealthy channels.
* Set to 0 to disable. Default: 5.
*/
channelHealthCheckMinutes?: number;
};

View File

@@ -48,6 +48,7 @@ import { createEmptyPluginRegistry } from "../plugins/registry.js";
import { getTotalQueueSize } from "../process/command-queue.js";
import { runOnboardingWizard } from "../wizard/onboarding.js";
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
import { startChannelHealthMonitor } from "./channel-health-monitor.js";
import { startGatewayConfigReloader } from "./config-reload.js";
import { ExecApprovalManager } from "./exec-approval-manager.js";
import { NodeRegistry } from "./node-registry.js";
@@ -502,6 +503,15 @@ export async function startGatewayServer(
}
: startHeartbeatRunner({ cfg: cfgAtStart });
const healthCheckMinutes = cfgAtStart.gateway?.channelHealthCheckMinutes;
const healthCheckDisabled = healthCheckMinutes === 0;
const channelHealthMonitor = healthCheckDisabled
? null
: startChannelHealthMonitor({
channelManager,
checkIntervalMs: (healthCheckMinutes ?? 5) * 60_000,
});
if (!minimalTestGateway) {
void cron.start().catch((err) => logCron.error(`failed to start: ${String(err)}`));
}
@@ -720,6 +730,7 @@ export async function startGatewayServer(
}
skillsChangeUnsub();
authRateLimiter?.dispose();
channelHealthMonitor?.stop();
await close(opts);
},
};