boring-cluster
Advanced tools
Comparing version 1.0.5 to 1.1.0
var cluster = require('cluster') | ||
var cpus = require('os').cpus | ||
var len = cpus().length | ||
function boringCluster (mod) { | ||
function boringCluster (mod, opt) { | ||
var opts = opt || {} | ||
var len = opts.workers || cpus().length | ||
var name = opts.name || '' | ||
if (cluster.isMaster) { | ||
@@ -13,3 +14,3 @@ for (var i = 0; i < len; i++) { | ||
cluster.on('exit', function (worker) { | ||
console.log(worker.process.pid + ' died; forking.') | ||
console.log(name + name ? ' ' : '' + worker.process.pid + ' died; forking.') | ||
cluster.fork() | ||
@@ -16,0 +17,0 @@ }) |
{ | ||
"name": "boring-cluster", | ||
"description": "A really boring cluster module", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Zac Anger", |
@@ -24,2 +24,13 @@ # boring-cluster | ||
An optional second argument can be passed with the shape | ||
```javascript | ||
{ workers: number, name: string } | ||
``` | ||
Example: | ||
```javascript | ||
cluster(resolve(__dirname, 'some-thing'), { workers: 2, name: 'My Awesome App' }) | ||
``` | ||
Full example with an Express server: | ||
@@ -31,3 +42,6 @@ | ||
const { resolve } = require('path') | ||
cluster(resolve(__dirname, 'server')) | ||
cluster( | ||
resolve(__dirname, 'server'), | ||
{ name: 'sweet server', workers: 2 } | ||
) | ||
@@ -34,0 +48,0 @@ // server.js |
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
3646
19
65