Quellcode durchsuchen

Fix use the physical CPU count from Fastify (#7988)

JaeHyeok Kim vor 2 Jahren
Ursprung
Commit
fe2ff26637

+ 2 - 2
frameworks/JavaScript/fastify/app.js

@@ -1,11 +1,11 @@
 const cluster = require("cluster");
-const numCPUs = require("os").cpus().length;
+const physicalCpuCount = require("physical-cpu-count")
 
 if (cluster.isPrimary) {
   console.log(`Primary ${process.pid} is running`);
 
   // Fork workers.
-  for (let i = 0; i < numCPUs; i++) {
+  for (let i = 0; i < physicalCpuCount; i++) {
     cluster.fork();
   }
 

+ 1 - 1
frameworks/JavaScript/fastify/fastify-mysql.dockerfile

@@ -1,4 +1,4 @@
-FROM node:18.12.1-alpine
+FROM node:18.12.1-slim
 
 COPY ./ ./
 

+ 1 - 1
frameworks/JavaScript/fastify/fastify-postgres.dockerfile

@@ -1,4 +1,4 @@
-FROM node:18.12.1-alpine
+FROM node:18.12.1-slim
 
 COPY ./ ./
 

+ 1 - 1
frameworks/JavaScript/fastify/fastify.dockerfile

@@ -1,4 +1,4 @@
-FROM node:18.12.1-alpine
+FROM node:18.12.1-slim
 
 COPY ./ ./
 

+ 2 - 1
frameworks/JavaScript/fastify/package.json

@@ -11,6 +11,7 @@
     "knex": "2.4.2",
     "mongodb": "3.5.9",
     "mysql2": "2.2.5",
-    "pg": "8.5.1"
+    "pg": "8.5.1",
+    "physical-cpu-count": "^2.0.0"
   }
 }