File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import { Application } from '@ditsmod/core ' ;
1
+ import cluster from 'node:cluster ' ;
2
2
import type { ServerOptions } from 'node:http' ;
3
+ import { availableParallelism } from 'node:os' ;
4
+ import { Application } from '@ditsmod/core' ;
3
5
4
6
import { AppModule } from './app/app.module.js' ;
5
7
6
- const serverOptions : ServerOptions = { keepAlive : true , keepAliveTimeout : 0 } ;
7
- const app = await new Application ( ) . bootstrap ( AppModule , { serverOptions } ) ;
8
- app . server . listen ( 3000 , '0.0.0.0' ) ;
8
+ const numCpus = availableParallelism ( ) ;
9
+
10
+ if ( numCpus > 1 && cluster . isPrimary ) {
11
+ for ( let i = 0 ; i < numCpus ; i ++ ) {
12
+ cluster . fork ( ) ;
13
+ }
14
+ } else {
15
+ const serverOptions : ServerOptions = { keepAlive : true , keepAliveTimeout : 0 } ;
16
+ const app = await new Application ( ) . bootstrap ( AppModule , { serverOptions } ) ;
17
+ app . server . listen ( 3000 , '0.0.0.0' ) ;
18
+ }
You can’t perform that action at this time.
0 commit comments