|
@@ -1,15 +1,16 @@
|
|
|
const cluster = require('cluster');
|
|
|
const numCPUs = require('os').cpus().length;
|
|
|
|
|
|
-if (cluster.isMaster) {
|
|
|
+if (cluster.isPrimary) {
|
|
|
+ console.log(`Primary ${process.pid} is running`);
|
|
|
+
|
|
|
// Fork workers.
|
|
|
for (let i = 0; i < numCPUs; i++) {
|
|
|
cluster.fork();
|
|
|
}
|
|
|
|
|
|
- console.log('Master starting ' + new Date().toISOString(" "));
|
|
|
cluster.on('exit', (worker, code, signal) => {
|
|
|
- process.exit(1);
|
|
|
+ console.log(`worker ${worker.process.pid} died`);
|
|
|
});
|
|
|
} else {
|
|
|
// worker task
|