Coder Social home page Coder Social logo

feathers-cluster's Introduction

feathers-cluster Build Status

Easily take advantage of multi-core systems for Featherjs.

Getting Started

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
    cluster: function(cluster) {
        // See http://nodejs.org/api/cluster.html
        cluster.on('fork', function (worker) {
            console.log('forked worker ' + worker.process.pid);
        });
        cluster.on('listening', function(worker, address) {
            console.log('worker ' + worker.process.pid + ' is now connected to ' + address.address + ':' + address.port);
        });
        cluster.on('exit', function(worker, code, signal) {
            console.log('worker ' + worker.process.pid + ' died');
        });
    },
    // Important: Do NOT configure Socket.io yourself, 
    // instead put your Socket.io configuration in the function below.
    socketio: function(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
    }
}));

// ....

Documentation

See the docs.

Author

License

Copyright (c) 2014 Glavin Wiechert

Licensed under the MIT license.

feathers-cluster's People

Contributors

glavin001 avatar

Stargazers

André Philip avatar Antony avatar  avatar Barry Buck avatar JIN TECH avatar Dekel Barzilay avatar Hairok avatar Juan Carlos Christensen avatar Winston Fassett avatar Joshua Toenyes avatar Arnaud Valensi avatar Keegan McCallum avatar Brad Pillow avatar Vu Le avatar Will Sahatdjian avatar  avatar

Watchers

André Philip avatar James Cloos avatar  avatar Antony avatar  avatar

feathers-cluster's Issues

Proxy Socketio and Primus

To allow the usual configuration usage of Socketio and primus, their functions must be proxied and then called later after configuration with Cluster is complete.

var oldFun = feathers.socketio;
feathers.socketio = function()
{
// Setup Socketio for Clustering

// Continue original setup
oldFun.apply(app, arguments);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.