mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-26 14:57:38 +00:00
fix: Roll back multithreading
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
070c471a7e
commit
042301995d
1 changed files with 4 additions and 19 deletions
23
server.js
23
server.js
|
|
@ -10,8 +10,6 @@ const minify = require('express-minify');
|
|||
const postcssMiddleware = require('postcss-middleware');
|
||||
const tmpdir = require('os').tmpdir();
|
||||
const path = require('path');
|
||||
const cluster = require('cluster');
|
||||
const numCPUs = require('os').cpus().length;
|
||||
|
||||
// Server
|
||||
var PORT = process.env.PORT || 8080;
|
||||
|
|
@ -62,20 +60,7 @@ app.use(require('./middleware/load-options'));
|
|||
app.post('/', require('./routes/post'));
|
||||
app.get('/*', require('./routes/get'));
|
||||
|
||||
// If the current process is the main one
|
||||
if (cluster.isMaster) {
|
||||
// Create processes relative to amount of CPUs
|
||||
Array.from({
|
||||
length: numCPUs
|
||||
}, () => cluster.fork());
|
||||
|
||||
// When worker closed
|
||||
cluster.on('exit', worker => {
|
||||
console.log(`❌ Worker ${worker.process.pid} died.`);
|
||||
});
|
||||
} else {
|
||||
// Start listening for HTTP requests
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 on http://localhost:${PORT}`);
|
||||
});
|
||||
}
|
||||
// Start listening for HTTP requests
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 on http://localhost:${PORT}`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue