How to use the socketcluster.SocketCluster function in socketcluster

To help you get started, we’ve selected a few socketcluster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jondubois / iogrid / server.js View on Github external
var start = function () {
  var socketCluster = new SocketCluster(options);

  if (masterControllerPath) {
    var masterController = require(masterControllerPath);
    masterController.run(socketCluster);
  }

  if (environment == 'dev') {
    // This will cause SC workers to reboot when code changes anywhere in the app directory.
    // The second options argument here is passed directly to chokidar.
    // See https://github.com/paulmillr/chokidar#api for details.
    console.log(`   !! The sc-hot-reboot plugin is watching for code changes in the ${__dirname} directory`);
    scHotReboot.attach(socketCluster, {
      cwd: __dirname,
      ignored: ['public', 'node_modules', 'README.md', 'Dockerfile', 'server.js', 'broker.js', /[\/\\]\./]
    });
  }
github epochtalk / epochtalk / websocket-server / index.js View on Github external
return new Promise(function(resolve) {
        var socketCluster = new SocketCluster({
          authKey: config.authKey,
          workers: config.workers,
          brokers: config.brokers,
          wsEngine: config.wsEngine,
          protocol: config.protocol,
          protocolOptions: config.protocolOptions,
          port: config.port,
          host: config.host,
          appName: 'ept-ws',
          workerController: path.normalize(__dirname + '/worker.js'),
          allowClientPublish: false
        });
        return resolve(socketCluster);
      })
      // cleanup (process exit, flushes db)
github mattkrick / meatier / src / server / server.js View on Github external
export const options = {
  authKey: process.env.JWT_SECRET,
  logLevel: 1,
  // change this to scale vertically
  workers: 1 || numCpus,
  brokers: 1,
  port: process.env.PORT || 3000,
  appName: 'Meatier',
  allowClientPublish: false,
  initController: path.join(__dirname, '/init.js'),
  workerController: path.join(__dirname, '/worker.js'),
  brokerController: path.join(__dirname, '/broker.js'),
  socketChannelLimit: 1000,
  rebootWorkerOnCrash: true
};
new SocketCluster(options); // eslint-disable-line no-new
github zalmoxisus / remotedev-server / index.js View on Github external
if (logLevel >= LOG_LEVEL_ERROR) {
          console.error(err);
        }
        return;
      }
      if (port !== p) {
        if (logLevel >= LOG_LEVEL_WARN) {
          console.log('[RemoteDev] Server port ' + port + ' is already used.');
        }
        resolve({ portAlreadyUsed: true, on: function(status, cb) { cb(); } });
      } else {
        if (logLevel >= LOG_LEVEL_INFO) {
          console.log('[RemoteDev] Start server...');
          console.log(repeat('-', 80) + '\n');
        }
        resolve(new SocketCluster(options));
      }
    });
  });
github IdleLands / IdleLands3 / socketcluster / server.js View on Github external
var ip = _(os.networkInterfaces())
  .values()
  .flatten()
  .filter(val => val.family === 'IPv4' && val.internal === false)
  .map('address')
  .first();

if(ip) {
  console.log(`Your IP is: ${ip}`);
}

process.on('unhandledRejection', function(reason, p) {
  console.log('Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});

var socketCluster = new SocketCluster({
  workers: Number(argv.w) || 1,
  stores: Number(argv.s) || 1,
  port: Number(argv.p) || process.env.PORT || 8080,
  appName: argv.n || 'reactive-retro',
  initController: __dirname + '/init.js',
  workerController: __dirname + '/worker.js',
  brokerController: __dirname + '/broker.js',
  socketChannelLimit: 100,
  rebootWorkerOnCrash: argv['auto-reboot'] != false,
  logLevel: process.env.NODE_ENV === 'production' ? 3 : 1
});

socketCluster.on('fail', function(e) {
  console.error(e);
});
github DragonsInn / BIRD3 / node-lib / socketcluster_worker.js View on Github external
(function FrontentWorker(conf) {
    global.config = global.config || conf;

    var socketCluster = new SocketCluster({
        workers: config.maxWorkers || 4,
        stores: 1,
        port: config.BIRD3.http_port,
        host: config.BIRD3.host,
        appName: config.app.name,
        workerController: require.resolve("./socketcluster/worker"),
        storeController: require.resolve("./socketcluster/store"),
        storeOptions: {
            host: '127.0.0.1',
            port: 6379
        },
        socketChannelLimit: 100,
        rebootWorkerOnCrash: config.debug || false
    });
    house.addShutdownHandler(function(ctx, next){
        socketCluster.killWorkers();
github DragonsInn / BIRD3 / app / Backend / Service / SocketCluster.js View on Github external
export function run(workerConf, house) {
    var config = BIRD3.config;
    var socketCluster = new SocketCluster({
        workers: config.maxWorkers || 4,
        stores: 1,
        port: config.BIRD3.http_port,
        host: config.BIRD3.host,
        appName: config.app.name,
        initController: path.join(BIRD3.root, "app/Backend/SocketCluster/Init"),
        workerController: path.join(BIRD3.root, "app/Backend/SocketCluster/Worker"),
        brokerController: path.join(BIRD3.root, "app/Backend/SocketCluster/Broker"),
        brokerOptions: {
            host: '127.0.0.1',
            port: 6379
        },
        workerOptions: workerConf.config,
        socketChannelLimit: 100,
        rebootWorkerOnCrash: config.debug || false
    });
github zalmoxisus / remote-redux-devtools / bin / remotedev.js View on Github external
#! /usr/bin/env node
var argv = require('minimist')(process.argv.slice(2));
var SocketCluster = require('socketcluster').SocketCluster;

var socketCluster = new SocketCluster({
  host: argv.hostname || null,
  port: Number(argv.port) || 8000,
  workerController: __dirname + '/worker.js',
  allowClientPublish: false
});
github geekuillaume / ChatUp / server.js View on Github external
var argv = require('minimist')(process.argv.slice(2));
var SocketCluster = require('socketcluster').SocketCluster;

var socketCluster = new SocketCluster({
  workers: Number(argv.w) || 4,
  stores: Number(argv.s) || 1,
  port: Number(argv.p) || 8001,
  appName: argv.n || 'chatup',
  workerController: __dirname + '/worker.js',
  storeController: __dirname + '/store.js',
  socketChannelLimit: 100,
  rebootWorkerOnCrash: false,
  logLevel: 3,
  secretKey: "jlshflquynlorqiupoaziwpodfboquypourmwoquybrncqmoeipçuf",
  origins: '*:*',
  storeOptions: {
    host: process.env.REDIS_HOST || "localhost",
    port: process.env.REDIS_PORT || 6379
  }
});

socketcluster

Highly scalable realtime framework with support for async/await

MIT
Latest version published 18 days ago

Package Health Score

67 / 100
Full package analysis