cmanager
v0.0.16
Published
Lightweight cluster manager.
Downloads
1
Readme
CManager
Lightweight cluster manager for node.js
Installation
$ npm install cmanager
Running Tests
Install dev dependencies.
$ npm install
Check code quality.
$ npm run lint
Features
- maintains number of workers (default = 1 worker per CPU core)
- kills unresponsive workers
- provides an easy to use, event-driven interface
Example
'use strict';
var cmanager = require('cmanager');
cmanager.on('master', function (workers) {
console.log('I am the master.', workers);
});
cmanager.on('worker', function (worker) {
console.log('I am a worker.', worker);
});
cmanager.on('kill', function (worker) {
console.log('This worker has benn killed:', worker);
});
cmanager.init(); // only once
Configuration
Using cmanager.init
cmanager.init({ numberOfworkers: 4 });
Using cmanager.configure
cmanager.configure({ numberOfWorkers: 4 });
Options
- numberOfWorkers : Number of workers. defaults to os.cpus().length
- frequency : Frequency of worker reports. defaults to 1000
- maxAge : The maximum gap between two reports. defaults to 5000
- respawn : Respawn unresponsive workers. defaults to true
Deprecated features
// deprecated since v0.0.15
cmanager.fork();
// use cmanager.init instead
cmanager.init();
License
MIT