feat(ql3): establish 3.0 incubation baseline

This commit is contained in:
whyour
2026-08-12 00:25:26 +08:00
parent 4bf92dcfeb
commit c699c32461
2817 changed files with 779642 additions and 653 deletions
+29 -3
View File
@@ -23,6 +23,9 @@ class Application {
private app: express.Application;
private httpServerService?: HttpServerService;
private grpcServerService?: GrpcServerService;
private manualPrimaryRuntime?: {
stop(): Promise<'drained' | 'timed_out'>;
};
private isShuttingDown = false;
private workerMetadataMap = new Map<number, WorkerMetadata>();
private httpWorker?: Worker;
@@ -242,10 +245,18 @@ class Application {
const appLoader = await import('./loaders/app');
await appLoader.default({ app: this.app });
const server = await this.httpServerService.initialize(
this.app,
config.port,
const { bootstrapDefaultManualPrimaryRuntime } = await import(
'./runtime/adapters/legacy/bootstrapDefaultManualPrimaryRuntime'
);
this.manualPrimaryRuntime = await bootstrapDefaultManualPrimaryRuntime();
let server;
try {
server = await this.httpServerService.initialize(this.app, config.port);
} catch (error) {
await this.stopManualPrimaryRuntime();
throw error;
}
const serverLoader = await import('./loaders/server');
await (serverLoader.default as any)({ server });
@@ -289,6 +300,7 @@ class Application {
try {
if (serviceType === 'http') {
await this.stopManualPrimaryRuntime();
await this.httpServerService?.shutdown();
} else {
await this.grpcServerService?.shutdown();
@@ -299,6 +311,20 @@ class Application {
process.exit(1);
}
}
private async stopManualPrimaryRuntime(): Promise<void> {
const runtime = this.manualPrimaryRuntime;
this.manualPrimaryRuntime = undefined;
if (!runtime) return;
try {
const result = await runtime.stop();
if (result === 'timed_out') {
Logger.warn('[runtime-activation] shutdown timed out');
}
} catch {
Logger.error('[runtime-activation] shutdown failed');
}
}
}
const app = new Application();