Skip to content

Commit

Permalink
Revert "Fix use the physical CPU count from Express (#7986)" (#8042)
Browse files Browse the repository at this point in the history
This reverts commit bb94cc2.
  • Loading branch information
JHyeok authored Mar 17, 2023
1 parent 0fe7845 commit 59cf159
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
8 changes: 3 additions & 5 deletions frameworks/JavaScript/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const cluster = require('cluster'),
physicalCpuCount = require('physical-cpu-count'),
numCPUs = require('os').cpus().length,
express = require('express');

const bodyParser = require('body-parser');
Expand All @@ -13,7 +13,7 @@ if (cluster.isPrimary) {
console.log(`Primary ${process.pid} is running`);

// Fork workers.
for (let i = 0; i < physicalCpuCount; i++) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

Expand Down Expand Up @@ -41,7 +41,5 @@ if (cluster.isPrimary) {
app.get('/plaintext', (req, res) =>
res.header('Content-Type', 'text/plain').send('Hello, World!'));

app.listen(8080, () => {
console.log('listening on port 8080');
});
app.listen(8080);
}
8 changes: 3 additions & 5 deletions frameworks/JavaScript/express/mongodb-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const cluster = require('cluster'),
physicalCpuCount = require('physical-cpu-count'),
numCPUs = require('os').cpus().length,
express = require('express'),
mongoose = require('mongoose'),
conn = mongoose.connect('mongodb://tfb-database/hello_world');
Expand Down Expand Up @@ -33,7 +33,7 @@ const FortuneSchema = new mongoose.Schema({

if (cluster.isPrimary) {
// Fork workers.
for (let i = 0; i < physicalCpuCount; i++) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

Expand Down Expand Up @@ -101,7 +101,5 @@ if (cluster.isPrimary) {
res.send(results);
});

app.listen(8080, () => {
console.log('listening on port 8080');
});
app.listen(8080);
}
8 changes: 3 additions & 5 deletions frameworks/JavaScript/express/mysql-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const cluster = require('cluster'),
physicalCpuCount = require('physical-cpu-count'),
numCPUs = require('os').cpus().length,
express = require('express'),
Sequelize = require('sequelize');

Expand Down Expand Up @@ -45,7 +45,7 @@ const Fortune = sequelize.define('Fortune', {

if (cluster.isPrimary) {
// Fork workers.
for (let i = 0; i < physicalCpuCount; i++) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

Expand Down Expand Up @@ -127,7 +127,5 @@ if (cluster.isPrimary) {
res.send(results);
});

app.listen(8080, () => {
console.log('listening on port 8080');
});
app.listen(8080);
}
1 change: 0 additions & 1 deletion frameworks/JavaScript/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"mysql2": "2.2.5",
"pg": "8.5.0",
"pg-promise": "10.7.3",
"physical-cpu-count": "^2.0.0",
"pug": "2.0.1",
"sequelize": "5.15.1"
}
Expand Down
4 changes: 2 additions & 2 deletions frameworks/JavaScript/express/postgresql-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Module dependencies.
*/
const cluster = require('cluster'),
physicalCpuCount = require('physical-cpu-count'),
numCPUs = require('os').cpus().length,
express = require('express'),
helper = require('./helper');

Expand Down Expand Up @@ -51,7 +51,7 @@ const randomWorldPromise = () => {

if (cluster.isPrimary) {
// Fork workers.
for (let i = 0; i < physicalCpuCount; i++) {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

Expand Down

0 comments on commit 59cf159

Please sign in to comment.