Skip to content

Commit dc23e92

Browse files
committed
docs: document gateway runtime startup
1 parent a3f495e commit dc23e92

8 files changed

Lines changed: 20 additions & 0 deletions

src/gateway/server-plugin-bootstrap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway plugin bootstrap helpers.
2+
// Applies activation config, installs runtime bindings, loads and pins plugins.
13
import { primeConfiguredBindingRegistry } from "../channels/plugins/binding-registry.js";
24
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
35
import type { OpenClawConfig } from "../config/types.openclaw.js";

src/gateway/server-runtime-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway startup runtime-config resolver.
2+
// Normalizes bind/auth/HTTP/Tailscale/hook settings before server construction.
13
import type {
24
GatewayAuthConfig,
35
GatewayBindMode,

src/gateway/server-runtime-handles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway mutable runtime handles.
2+
// Provides stop-safe defaults for timers, sidecars, subscriptions, and services.
13
import type { OpenClawConfig } from "../config/types.openclaw.js";
24
import type { HeartbeatRunner } from "../infra/heartbeat-runner.js";
35
import type { ChannelHealthMonitor } from "./channel-health-monitor.js";
@@ -37,6 +39,8 @@ export type GatewayServerMutableState = {
3739
/** Creates gateway mutable state with inert handles that are safe to stop before startup finishes. */
3840
export function createGatewayServerMutableState(): GatewayServerMutableState {
3941
const noopInterval = () => {
42+
// Dummy unref'd timers give shutdown code a concrete handle to clear even
43+
// when startup exits before real maintenance intervals are installed.
4044
const timer = setInterval(() => {}, 1 << 30);
4145
timer.unref?.();
4246
return timer;

src/gateway/server-runtime-services.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway post-ready runtime services.
2+
// Starts delayed maintenance, cron, heartbeat, recovery, and pricing refresh work.
13
import type { OpenClawConfig } from "../config/types.openclaw.js";
24
import { isVitestRuntimeEnv } from "../infra/env.js";
35
import { startHeartbeatRunner, type HeartbeatRunner } from "../infra/heartbeat-runner.js";
@@ -35,6 +37,8 @@ function clearGatewayMaintenanceHandles(maintenance: GatewayMaintenanceHandles |
3537
if (!maintenance) {
3638
return;
3739
}
40+
// Maintenance startup can race shutdown. Clear every interval handle here so
41+
// callers can discard partially-created maintenance safely.
3842
clearInterval(maintenance.tickInterval);
3943
clearInterval(maintenance.healthInterval);
4044
clearInterval(maintenance.dedupeCleanup);

src/gateway/server-runtime-startup-services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway startup-time runtime services.
2+
// Starts mode-dependent background monitors with inert handles for disabled paths.
13
import type { OpenClawConfig } from "../config/types.openclaw.js";
24
import type { ChannelHealthMonitor } from "./channel-health-monitor.js";
35
import { startChannelHealthMonitor } from "./channel-health-monitor.js";

src/gateway/server-runtime-state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway HTTP/WebSocket runtime state factory.
2+
// Builds one server runtime with pinned plugin registries and lazy route handlers.
13
import type { IncomingMessage, Server as HttpServer, ServerResponse } from "node:http";
24
import type { Duplex } from "node:stream";
35
import { WebSocketServer } from "ws";

src/gateway/server-startup-early.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway early-startup runtime helpers.
2+
// Starts discovery, remote skills, task maintenance, and delayed maintenance setup.
13
import type { GatewayTailscaleMode } from "../config/types.gateway.js";
24
import type { OpenClawConfig } from "../config/types.openclaw.js";
35
import { resolveCronJobsStorePath } from "../cron/store.js";

src/gateway/server-startup-post-attach.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gateway post-attach startup sidecars.
2+
// Schedules warmups, sentinels, update checks, memory backend, and plugin services.
13
import fs from "node:fs";
24
import os from "node:os";
35
import path from "node:path";

0 commit comments

Comments
 (0)