lfryc / fh-cluster

Wraps node cluster module to allow cleaner usage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fh-cluster

Wraps node cluster module to allow cleaner usage

Install

npm install fh-cluster --save

Usage

Import the module, pass your application entrypoint function to it:

var express = require('express');
var fhcluster = require('fh-cluster');

function exampleApp(clusterWorker) {

  var app = express();
  app.get('/', function(req, res) {
    res.status(200).send('hello from worker #' + clusterWorker.id + '\n');
  });

  app.listen(8081);
}

var numWorkers = 4;
fhcluster(exampleApp, numWorkers);

About

Wraps node cluster module to allow cleaner usage

License:Apache License 2.0


Languages

Language:JavaScript 100.0%