Synchronize server startup
This prevents an edge case where the server begins processing inbound API / AP requests before any of the chart / management daemons are ready, potentially leading to incorrect chart statistics.
This commit is contained in:
@@ -19,17 +19,18 @@ export async function server() {
|
||||
logger: new NestLogger(),
|
||||
});
|
||||
|
||||
const serverService = app.get(ServerService);
|
||||
await serverService.launch();
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
app.get(ChartManagementService).start();
|
||||
await app.get(ChartManagementService).start();
|
||||
}
|
||||
if (!envOption.noDaemons) {
|
||||
app.get(QueueStatsService).start();
|
||||
app.get(ServerStatsService).start();
|
||||
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();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -38,8 +39,8 @@ export async function jobQueue() {
|
||||
logger: new NestLogger(),
|
||||
});
|
||||
|
||||
jobQueue.get(QueueProcessorService).start();
|
||||
jobQueue.get(ChartManagementService).start();
|
||||
await jobQueue.get(QueueProcessorService).start();
|
||||
await jobQueue.get(ChartManagementService).start();
|
||||
|
||||
return jobQueue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user