mushroom
v0.0.4
Published
Mushroom sprouts a never-ending set of child processes which can report statistics back to the host. Like multi-process forever.
Downloads
8
Readme
Mushroom
Manages multiple Node processes better than forever+cluster
** Alpha, use at your own risk **
Mushroom is like forever combined with cluster. It succinctly provides the ability to launch a Node process to serve on a port and restart it when it crashes, while providing a simple way for child processes to report performance data to the master.
Mushroom offers:
- The means to keep one or more Node instances alive even when they crash
- Performance and health tracking of instances
Child processes report back to the master over HTTP (intentionally not IPC or a pipe) with status information, like memory used and a tally of performance events. Child process stdout and stderr are also consumed and aggregated by the master. Mushroom is intended for scenarios where a load balancer (e.g. nginx or hardware) balances to one or many servers, each with a Mushroom master which controls many processes ("spores") on known ports. It is possible to make the master act as the load balancer but Mushroom was designed for an external one for reasons of performance, low latency and scalability.
Installation
npm install mushroom
Usage
** Master (e.g. master.js) **
var shroom = require("mushroom").shroom;
shroom.spawn(["main.js"], 2000);
shroom.spawn(["main.js"], 2001);
shroom.spawn(["main.js"], 2002);
** Spore (e.g. main.js) **
var spore = require("mushroom").spore();
var http = require("http");
http.createServer(function(request, response)
{
spore.tally("hit", 1, {url: request.url});
}).listen(spore.port);