Skip to content

Simple yet powerful wrapper over node.js cluster API.

License

Notifications You must be signed in to change notification settings

setthase/division

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3fef559 · Sep 10, 2015

History

81 Commits
Jan 1, 2015
Jun 19, 2015
Mar 15, 2015
Jun 12, 2015
Mar 27, 2015
Nov 20, 2014
Nov 20, 2014
Sep 10, 2015
Dec 10, 2014
Nov 20, 2014
Aug 2, 2013
Mar 27, 2015
Dec 10, 2014
Jun 26, 2015

Repository files navigation

division

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 = require('division');
var cluster = new division();

// Configuration for development environment
cluster.configure('development', function () {
  // Put your development configuration here
  cluster.set('args', ['--some-process-args', 'send-to-workers']);
});

// Configuration for production environment
cluster.configure('production', function () {
  // Put your production configuration here
  cluster.enable('silent');
});

// Configuration for all environments
// TIP: this is pointing to cluster
cluster.configure(function () {
  this.set('path', 'app.js');
});

// You can also set settings without configuration block
cluster.set('size', 2);

// Use extensions
// TIP: You can chain (almost) all methods
cluster.use('debug').use('signals');

// Start your application as a cluster!
cluster.run(function () {
  // `this` is pointing to the Master instance
});

You can set environment while launching application - in this way:

$ NODE_ENV=production node cluster.js

Minimal configuration example

var division = require('division');
// You can pass settings in constructor
var cluster = new division({ path : 'app.js' });

cluster.run();

API Reference

For API reference take a look at docs directory.

About

Simple yet powerful wrapper over node.js cluster API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published