fix(GOV-009): 完成脚手架审查整改

This commit is contained in:
2026-08-13 18:30:57 +08:00
parent dcdf634457
commit 3a8120a33a
47 changed files with 752 additions and 101 deletions
+8 -4
View File
@@ -2,35 +2,39 @@ import 'reflect-metadata';
import { type INestApplicationContext, type NestApplicationOptions } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import path from 'node:path';
import { loadSchedulerProcessConfig } from '../../../libs/config/src/load-process-env';
import {
toSafeRuntimeSummary,
type SchedulerRuntimeConfig,
} from '../../../libs/config/src/runtime-config';
import { waitForShutdownSignal } from '../../../libs/infrastructure/src/process-lifecycle';
import { SchedulerModule } from './scheduler.module';
/** Scheduler 引导参数确保模块只读取本进程已校验的最小配置。 */
interface BootstrapSchedulerOptions {
config: SchedulerRuntimeConfig;
logger?: NestApplicationOptions['logger'];
}
/** 启动无 HTTP 端口的 Scheduler 应用上下文,生命周期由命令入口持有。 */
export async function bootstrapScheduler(
options: BootstrapSchedulerOptions,
): Promise<INestApplicationContext> {
const app = await NestFactory.createApplicationContext(SchedulerModule, {
const app = await NestFactory.createApplicationContext(SchedulerModule.register(options.config), {
logger: options.logger,
});
app.enableShutdownHooks();
return app;
}
async function runScheduler(): Promise<void> {
const config = loadSchedulerProcessConfig();
console.info('Scheduler 进程启动配置', toSafeRuntimeSummary(config));
await bootstrapScheduler({ config });
const app = await bootstrapScheduler({ config });
await waitForShutdownSignal(app);
}
if (require.main === module) {
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(__filename)) {
void runScheduler();
}