mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 01:10:44 +00:00
35 lines
1.2 KiB
TypeScript
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();
|
|
}
|