feat(GOV-009): 建立 NestJS 三进程基线

This commit is contained in:
2026-08-13 16:59:09 +08:00
parent 28d54186ad
commit 3fc703de0b
23 changed files with 3399 additions and 36 deletions
+36
View File
@@ -0,0 +1,36 @@
import 'reflect-metadata';
import { type INestApplicationContext, type NestApplicationOptions } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { loadWorkerProcessConfig } from '../../../libs/config/src/load-process-env';
import {
toSafeRuntimeSummary,
type WorkerRuntimeConfig,
} from '../../../libs/config/src/runtime-config';
import { WorkerModule } from './worker.module';
interface BootstrapWorkerOptions {
config: WorkerRuntimeConfig;
logger?: NestApplicationOptions['logger'];
}
export async function bootstrapWorker(
options: BootstrapWorkerOptions,
): Promise<INestApplicationContext> {
const app = await NestFactory.createApplicationContext(WorkerModule, {
logger: options.logger,
});
app.enableShutdownHooks();
return app;
}
async function runWorker(): Promise<void> {
const config = loadWorkerProcessConfig();
console.info('Worker 进程启动配置', toSafeRuntimeSummary(config));
await bootstrapWorker({ config });
}
if (require.main === module) {
void runWorker();
}
+4
View File
@@ -0,0 +1,4 @@
import { Module } from '@nestjs/common';
@Module({})
export class WorkerModule {}