From 7bff7962a64df250f9a00efa3917b3a7bb9713ff Mon Sep 17 00:00:00 2001 From: fly_mc Date: Mon, 16 Dec 2024 09:24:12 +0800 Subject: [PATCH] Revert "Synchronize server startup" This reverts commit 2c4fc485e4af2321a6fb2dea1a45e4f938685f2d. --- packages/backend/src/boot/common.ts | 20 ++++++++----------- .../backend/src/daemons/QueueStatsService.ts | 4 ++-- .../backend/src/daemons/ServerStatsService.ts | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/backend/src/boot/common.ts b/packages/backend/src/boot/common.ts index 9ff1efb3c..268c07582 100644 --- a/packages/backend/src/boot/common.ts +++ b/packages/backend/src/boot/common.ts @@ -12,25 +12,21 @@ import { QueueStatsService } from '@/daemons/QueueStatsService.js'; import { ServerStatsService } from '@/daemons/ServerStatsService.js'; import { ServerService } from '@/server/ServerService.js'; import { MainModule } from '@/MainModule.js'; -import { envOption } from '@/env.js'; export async function server() { const app = await NestFactory.createApplicationContext(MainModule, { logger: new NestLogger(), }); - if (process.env.NODE_ENV !== 'test') { - await app.get(ChartManagementService).start(); - } - if (!envOption.noDaemons) { - await app.get(QueueStatsService).start(); - await app.get(ServerStatsService).start(); - } - - // Start server last so the other services can register hooks first const serverService = app.get(ServerService); await serverService.launch(); + if (process.env.NODE_ENV !== 'test') { + app.get(ChartManagementService).start(); + app.get(QueueStatsService).start(); + app.get(ServerStatsService).start(); + } + return app; } @@ -39,8 +35,8 @@ export async function jobQueue() { logger: new NestLogger(), }); - await jobQueue.get(QueueProcessorService).start(); - await jobQueue.get(ChartManagementService).start(); + jobQueue.get(QueueProcessorService).start(); + jobQueue.get(ChartManagementService).start(); return jobQueue; } diff --git a/packages/backend/src/daemons/QueueStatsService.ts b/packages/backend/src/daemons/QueueStatsService.ts index 77fcd7133..ede104b9f 100644 --- a/packages/backend/src/daemons/QueueStatsService.ts +++ b/packages/backend/src/daemons/QueueStatsService.ts @@ -33,7 +33,7 @@ export class QueueStatsService implements OnApplicationShutdown { * Report queue stats regularly */ @bindThis - public async start(): Promise { + public start(): void { const log = [] as any[]; ev.on('requestQueueStatsLog', x => { @@ -82,7 +82,7 @@ export class QueueStatsService implements OnApplicationShutdown { activeInboxJobs = 0; }; - await tick(); + tick(); this.intervalId = setInterval(tick, interval); } diff --git a/packages/backend/src/daemons/ServerStatsService.ts b/packages/backend/src/daemons/ServerStatsService.ts index 63b50f9f6..d229efb12 100644 --- a/packages/backend/src/daemons/ServerStatsService.ts +++ b/packages/backend/src/daemons/ServerStatsService.ts @@ -68,7 +68,7 @@ export class ServerStatsService implements OnApplicationShutdown { if (log.length > 200) log.pop(); }; - await tick(); + tick(); this.intervalId = setInterval(tick, interval); }