






















@@ -1114,14 +1114,13 @@ export async function startGatewayServer(
11141114getActiveTaskCount = earlyRuntime.getActiveTaskCount;
11151115runtimeState.skillsChangeUnsub = earlyRuntime.skillsChangeUnsub;
111611161117-const [{ startGatewayEventSubscriptions }, gatewayRuntimeServices] = await startupTrace.measure(
1118-"runtime.post-early-imports",
1119-() =>
1117+const [{ startGatewayEventSubscriptions }, { startGatewayRuntimeServices }] =
1118+await startupTrace.measure("runtime.post-early-imports", () =>
11201119Promise.all([
11211120import("./server-runtime-subscriptions.js"),
1122-import("./server-runtime-services.js"),
1121+import("./server-runtime-startup-services.js"),
11231122]),
1124-);
1123+ );
11251124const runtimeSubscriptions = await startupTrace.measure("runtime.subscriptions", () =>
11261125startGatewayEventSubscriptions({
11271126 broadcast,
@@ -1138,7 +1137,7 @@ export async function startGatewayServer(
11381137Object.assign(runtimeState, runtimeSubscriptions);
1139113811401139const runtimeServices = await startupTrace.measure("runtime.services", () =>
1141-gatewayRuntimeServices.startGatewayRuntimeServices({
1140+startGatewayRuntimeServices({
11421141 minimalTestGateway,
11431142 cfgAtStart,
11441143 channelManager,
@@ -1516,6 +1515,13 @@ export async function startGatewayServer(
15161515const sessionDeliveryRecoveryMaxEnqueuedAt = Date.now();
15171516let postAttachRuntimeReturned = false;
15181517let scheduledServicesActivated = false;
1518+let scheduledServicesModulePromise: Promise<
1519+typeof import("./server-runtime-services.js")
1520+> | null = null;
1521+const loadScheduledServicesModule = () => {
1522+scheduledServicesModulePromise ??= import("./server-runtime-services.js");
1523+return scheduledServicesModulePromise;
1524+};
15191525const activateScheduledServicesWhenReady = () => {
15201526if (
15211527closePreludeStarted ||
@@ -1525,20 +1531,25 @@ export async function startGatewayServer(
15251531) {
15261532return;
15271533}
1528-const activated = gatewayRuntimeServices.activateGatewayScheduledServices({
1529- minimalTestGateway,
1530- cfgAtStart,
1531- deps,
1532- sessionDeliveryRecoveryMaxEnqueuedAt,
1533-cron: runtimeState.cronState.cron,
1534-startCron: false,
1535- logCron,
1536- log,
1537- pluginLookUpTable,
1538-});
15391534scheduledServicesActivated = true;
1540-runtimeState.heartbeatRunner = activated.heartbeatRunner;
1541-runtimeState.stopModelPricingRefresh = activated.stopModelPricingRefresh;
1535+void loadScheduledServicesModule().then((gatewayRuntimeServices) => {
1536+if (closePreludeStarted) {
1537+return;
1538+}
1539+const activated = gatewayRuntimeServices.activateGatewayScheduledServices({
1540+ minimalTestGateway,
1541+ cfgAtStart,
1542+ deps,
1543+ sessionDeliveryRecoveryMaxEnqueuedAt,
1544+cron: runtimeState.cronState.cron,
1545+startCron: false,
1546+ logCron,
1547+ log,
1548+ pluginLookUpTable,
1549+});
1550+runtimeState.heartbeatRunner = activated.heartbeatRunner;
1551+runtimeState.stopModelPricingRefresh = activated.stopModelPricingRefresh;
1552+});
15421553};
15431554({
15441555stopGatewayUpdateCheck: runtimeState.stopGatewayUpdateCheck,
@@ -1693,6 +1704,7 @@ export async function startGatewayServer(
16931704log.warn(`gateway: failed to promote config last-known-good backup: ${String(err)}`);
16941705});
16951706if (!minimalTestGateway) {
1707+const gatewayRuntimeServices = await loadScheduledServicesModule();
16961708postReadyMaintenanceTimer = gatewayRuntimeServices.scheduleGatewayPostReadyMaintenance({
16971709delayMs: POST_READY_MAINTENANCE_DELAY_MS,
16981710isClosing: () => closePreludeStarted,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。