UNPKG

597 BPlain TextView Raw
1import { Burn } from './core';
2import * as cluster from 'cluster';
3import * as os from 'os';
4
5
6export default class BurnCluster {
7 startCluster() {
8 const numCPUs = os.cpus().length;
9
10 if (cluster.isMaster) {
11 // Fork workers.
12 for (let i = 0; i < numCPUs; i++) {
13 cluster.fork();
14 }
15
16 cluster.on('exit', function (worker, code, signal) {
17 console.log('worker ' + worker.process.pid + ' died');
18 });
19 } else {
20 const app = new Burn;
21
22 app.run();
23 }
24 }
25}
26
27