Commit e57be634f673cd8157ff88a3431783ed35836643

Authored by Adhidarma Hadiwinoto
1 parent cfdcd17330
Exists in master and in 1 other branch dev

Auto jumlah anak

Showing 2 changed files with 6 additions and 3 deletions Side-by-side Diff

... ... @@ -10,5 +10,6 @@
10 10 }
11 11 },
12 12  
13   - "cluster": 0
  13 + "# cluster": "Diisi dengan boolean atau angka jumlah anak yang akan dibuat. Jika diisi boolean true, jumlah anak akan dihitung otomatis",
  14 + "cluster": false
14 15 }
15 16 \ No newline at end of file
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 {