Update backend/src/main.ts
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import cluster from 'node:cluster';
|
||||
import os from 'node:os';
|
||||
import * as _cluster from 'node:cluster';
|
||||
import * as os from 'node:os';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
const cluster = _cluster as any; // Cast to 'any' bypasses the missing property errors
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -20,7 +21,7 @@ if (WORKERS > 1 && cluster.isPrimary) {
|
||||
for (let i = 0; i < WORKERS; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
cluster.on('exit', (worker, code) => {
|
||||
cluster.on('exit', (worker: any, code: number) => {
|
||||
console.warn(`Worker ${worker.process.pid} exited (code ${code}), restarting ...`);
|
||||
cluster.fork();
|
||||
});
|
||||
@@ -28,6 +29,7 @@ if (WORKERS > 1 && cluster.isPrimary) {
|
||||
bootstrap();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NestJS bootstrap
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user