Commit e57be634f673cd8157ff88a3431783ed35836643
1 parent
cfdcd17330
Exists in
master
and in
1 other branch
Auto jumlah anak
Showing 2 changed files with 6 additions and 3 deletions Side-by-side Diff
config.sample.json
index.js
1 | 1 | process.chdir(__dirname); |
2 | + | |
2 | 3 | const fs = require('fs'); |
4 | +const numCPUs = require('os').cpus().length; | |
3 | 5 | |
4 | 6 | fs.writeFileSync('pid.txt', process.pid); |
5 | 7 | |
... | ... | @@ -14,8 +16,8 @@ const logger = require('komodo-sdk/logger'); |
14 | 16 | if (config.cluster && cluster.isMaster) { |
15 | 17 | logger.info(`Running on cluster mode. Master ${process.pid} is running`); |
16 | 18 | |
17 | - // eslint-disable-next-line no-plusplus | |
18 | - for (let i = 0; i < config.cluster; i++) { | |
19 | + const numberOfChildren = config.cluster === true ? numCPUs + 1 : config.cluster; | |
20 | + for (let i = 0; i < numberOfChildren; i += 1) { | |
19 | 21 | cluster.fork(); |
20 | 22 | } |
21 | 23 | } else { |