Beany
Dead-simple one-liner for clustered Node.js apps.
Runs X workers and respawns them if they go down. Correctly handles signals from the OS.
const beany = ; ;
$ node example
Started worker 1
Started worker 2
Started worker 3
Started worker 4
Installation
npm install --save beany
For older versions of node (< 4.x), use beany 2.x.
Use
;
Simplest; fork 1 worker per CPU core.
;
Specify a number of workers.
;
More options.
;
Handling signals (for cleanup on a kill signal, for instance).
All Options (with defaults)
;
A Complex example
const beany = ; ; // This will only be called once { console;} // This will be called four times { console; process;}
$ node example-complex.js
Started master
Started worker 1
Started worker 2
Started worker 3
Started worker 4
$ killall node
Worker 3 exiting...
Worker 4 exiting...
(cleanup would happen here)
(cleanup would happen here)
Worker 2 exiting...
(cleanup would happen here)
Worker 1 exiting...
(cleanup would happen here)
Tests
npm test