boring-cluster
Advanced tools
Comparing version 1.1.2 to 2.0.0
21
index.js
@@ -1,16 +0,17 @@ | ||
var cluster = require('cluster') | ||
var cpus = require('os').cpus | ||
const cluster = require('cluster') | ||
const { cpus } = require('os') | ||
function boringCluster (mod, opt) { | ||
var opts = opt || {} | ||
var len = opts.workers || cpus().length | ||
var name = opts.name || '' | ||
const boringCluster = (mod, opts = { | ||
workers: cpus().length, | ||
name: '' | ||
}) => { | ||
const { workers, name } = opts | ||
if (cluster.isMaster) { | ||
for (var i = 0; i < len; i++) { | ||
Array.from(workers).fill(null).forEach(() => { | ||
cluster.fork() | ||
} | ||
}) | ||
cluster.on('exit', function (worker) { | ||
console.log(name + name ? ' ' : '' + worker.process.pid + ' died; forking.') | ||
cluster.on('exit', (worker) => { | ||
console.log(`${name ? `${name} ` : ''} ${worker.process.pid} died; forking.`) | ||
cluster.fork() | ||
@@ -17,0 +18,0 @@ }) |
{ | ||
"name": "boring-cluster", | ||
"description": "A really boring cluster module", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"author": { | ||
@@ -42,3 +42,4 @@ "name": "Zac Anger", | ||
"babel-eslint": "8.2.2", | ||
"eslint-config-jane": "0.11.0", | ||
"eslint": "4.18.1", | ||
"eslint-config-jane": "0.11.1", | ||
"eslint-plugin-babel": "4.1.2", | ||
@@ -50,4 +51,4 @@ "eslint-plugin-import": "2.9.0", | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=6.4.0" | ||
} | ||
} |
@@ -59,3 +59,3 @@ # boring-cluster | ||
This is tested on Node as far back as 4.1.2, and may work on even more ancient | ||
This is tested on Node as far back as 6.4.0, and may work on even more ancient | ||
versions. | ||
@@ -62,0 +62,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4002
20
7