feathers-cluster

Easily take advantage of multi-core systems for Featherjs.

feathers-cluster

Easily take advantage of multi-core systems for Featherjs.

To install feathers-cluster from npm, run:

$ npm install feathers-cluster --save

Finally, to use the plugin in your Feathers app:

// Require 
var feathers = require('feathers');
var cluster = require('feathers-cluster');
// Get a Feathers server 
var app = feathers();
// ... 
 
// ===== Usage ===== 
// app.configure(cluster()); 
app.configure(cluster({
    // Customize 
    cores: 4, // Optional: Force number of cores, defaults to number of CPUs. 
    // Customize the Cluster 
    clusterfunction(cluster) {
        // See http://nodejs.org/api/cluster.html 
        cluster.on('fork', function (worker) {
            console.log('forked worker ' + worker.process.pid);
        });
        cluster.on('listening', function(workeraddress) {
            console.log('worker ' + worker.process.pid + ' is now connected to ' + address.address + ':' + address.port);
        });
        cluster.on('exit', function(workercodesignal) {
            console.log('worker ' + worker.process.pid + ' died');
        });
    },
    // Important: Do NOT configure Socket.io yourself,  
    // instead put your Socket.io configuration in the function below. 
    socketiofunction(io) {
        // Example Socket.io configuration 
        io.enable('browser client minification');  // send minified client 
        io.enable('browser client etag');          // apply etag caching logic based on version number 
        io.enable('browser client gzip');          // gzip the file 
        io.set('log level', 1);                    // reduce logging 
    }
}));
 
// .... 
 

See the docs.

Copyright (c) 2014 Glavin Wiechert

Licensed under the MIT license.