cluster-bomb
a node.js cluster management and monitoring system for explosive results
Usage
$ npm install cluster-bomb
Then just create an instance, configure with options like number of workers, and create callbacks for worker()
and master()
var clusterBomb = ; var bomb = ; bomb; bomb; bomb;
Results in...
$ node myclusterbomb.jsmaster is runningnew worker new worker new worker
Restarts
Setting restart:true
will auto-restart dead workers. A restart event is also emitted.
bomb; bomb; bomb;
Results in...
$ node restart.jsmaster is runninglaunching worker with pid 95072launching worker with pid 95073launching worker with pid 95074killing worker 2restarting 1 workerslaunching worker with pid 95075
Scaling
You can even scale up your workers...
bomb;
Results in...
$ node myclusterbomb.jsmaster is runningnew worker new worker new worker --> scaling upnew worker
Configure Options
workers
: [integer] Number of workers to fork. Defaults to the number of CPU's on the host systemrestart
: [boolean] Auto-restart workers that have died. Defaults to true.
API
configure(opts)
: Set your options hashworker(fn)
: Set the worker callback function. Callback contains a reference to the worker object.master(fn)
: Set the master callback function. Callback contains a reference to the cluster object.scale(num)
: Scale up your workers. (scale down coming soon)
License
MIT