なんかもうめっちゃ変えた

This commit is contained in:
syuilo
2022-09-18 03:27:08 +09:00
committed by GitHub
parent d9ab03f086
commit b75184ec8e
946 changed files with 41219 additions and 28839 deletions

View File

@@ -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