Overview
Simple yet powerful wrapper over node.js cluster API.
This module is inspired by impressive, but abandoned project Cluster created by TJ Holowaychuk.
Installation
$ npm install division
Running Tests
First go to module directory and install development dependencies:
$ npm install
Then you can test module typing:
$ npm test
Code coverage
To get code coverage results run:
$ npm run coverage
Reports are in coverage
directory.
Features
The most valuable feature: you don't need to change your code to working within cluster.
Other features:
- works with node version ≥ 0.10
- compatible with io.js (all tests green)
- standalone (i.e. without 3rd-party dependencies)
- zero-downtime restart
- maintains worker count
- forceful shutdown support
- graceful shutdown support
- bundled extensions
- debug: enable verbose debugging informations
- watch: reload cluster when files was changed
- signals: add ability to control cluster with POSIX signals
Examples
More examples you can find in examples
directory.
Standard configuration example
var division = ;var cluster = ; // Configuration for development environmentcluster; // Configuration for production environmentcluster; // Configuration for all environments// TIP: this is pointing to clustercluster; // You can also set settings without configuration blockcluster; // Use extensions// TIP: You can chain (almost) all methodscluster; // Start your application as a cluster!cluster;
You can set environment while launching application - in this way:
$ NODE_ENV=production node cluster.js
Minimal configuration example
var division = ;// You can pass settings in constructorvar cluster = path : 'app.js' ; cluster;
API Reference
For API reference take a look at docs directory.