Files
openclaw/src/gateway/server.ts
2026-04-28 02:26:27 +01:00

35 lines
1.2 KiB
TypeScript

export { truncateCloseReason } from "./server/close-reason.js";
export type { GatewayServer, GatewayServerOptions } from "./server.impl.js";
function emitStartupTrace(name: string, durationMs: number, totalMs: number): void {
if (!process.env.OPENCLAW_GATEWAY_STARTUP_TRACE) {
return;
}
process.stderr.write(
`[gateway] startup trace: ${name} ${durationMs.toFixed(1)}ms total=${totalMs.toFixed(1)}ms\n`,
);
}
async function loadServerImpl() {
const startupStartedAt = performance.now();
const before = performance.now();
try {
return await import("./server.impl.js");
} finally {
const now = performance.now();
emitStartupTrace("gateway.server-impl-import", now - before, now - startupStartedAt);
}
}
export async function startGatewayServer(
...args: Parameters<typeof import("./server.impl.js").startGatewayServer>
): ReturnType<typeof import("./server.impl.js").startGatewayServer> {
const mod = await loadServerImpl();
return await mod.startGatewayServer(...args);
}
export async function __resetModelCatalogCacheForTest(): Promise<void> {
const mod = await loadServerImpl();
await mod.__resetModelCatalogCacheForTest();
}