Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit e0fa211

Browse files
authored
Fix use the physical CPU count from NestJS (#7987)
1 parent fe2ff26 commit e0fa211

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

frameworks/TypeScript/nest/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"mongodb": "3.5.4",
2929
"mysql2": "2.1.0",
3030
"pg": "8.5.1",
31+
"physical-cpu-count": "^2.0.0",
3132
"point-of-view": "3.7.2",
3233
"reflect-metadata": "0.1.13",
3334
"rimraf": "3.0.2",

frameworks/TypeScript/nest/src/main.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { MongoModule } from './mongo/mongo.module';
99
import { join } from 'path';
1010
import { SqlModule } from './sql/sql.module';
1111
import cluster from 'cluster'
12-
import os = require('os');
12+
import physicalCpuCount from 'physical-cpu-count';
1313

1414
const port = process.env.PORT || 8080;
1515

@@ -58,8 +58,7 @@ async function bootstrapFastify() {
5858
}
5959

6060
if (cluster.isPrimary) {
61-
const cpus = os.cpus().length;
62-
for (let i = 0; i < cpus; i++) {
61+
for (let i = 0; i < physicalCpuCount; i++) {
6362
cluster.fork();
6463
}
6564

0 commit comments

Comments
 (0)