なんかもうめっちゃ変えた
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
import cluster from 'node:cluster';
|
||||
import { initDb } from '../db/postgre.js';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { envOption } from '@/env.js';
|
||||
import { ChartManagementService } from '@/core/chart/ChartManagementService.js';
|
||||
import { ServerService } from '@/server/ServerService.js';
|
||||
import { QueueProcessorService } from '@/queue/QueueProcessorService.js';
|
||||
import { AppModule } from '../AppModule.js';
|
||||
|
||||
/**
|
||||
* Init worker process
|
||||
*/
|
||||
export async function workerMain() {
|
||||
await initDb();
|
||||
const app = await NestFactory.createApplicationContext(AppModule);
|
||||
app.enableShutdownHooks();
|
||||
|
||||
// start server
|
||||
await import('../server/index.js').then(x => x.default());
|
||||
const serverService = app.get(ServerService);
|
||||
serverService.launch();
|
||||
|
||||
// start job queue
|
||||
import('../queue/index.js').then(x => x.default());
|
||||
if (!envOption.onlyServer) {
|
||||
const queueProcessorService = app.get(QueueProcessorService);
|
||||
queueProcessorService.start();
|
||||
}
|
||||
|
||||
app.get(ChartManagementService).run();
|
||||
|
||||
if (cluster.isWorker) {
|
||||
// Send a 'ready' message to parent process
|
||||
|
Reference in New Issue
Block a user