Skip to content
heynedimPublic

About

Run your application as cluster mode in middleware! ๐Ÿƒ

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

ย 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Grupo!

NPM Version

Run your application as cluster mode in middleware! ๐Ÿƒ

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install grupo

API

import grupo from "grupo";

grupo(options)

Grupo has options as parameter and has own logger in it. You can enable and disable it as you wish by using options. Run your application in cluster mode and choose how many thread you need.

Options

Grupo accepts these properties in the options object.

interface options {
  instance?: number;
  log?: boolean;
}

instance

Instance is counter for how many thread you wan't to use, of course is limit how much you have.

// Will use 3 thread
// The default value is 0, so will use all cores
app.use(
  grupo({
    instance: 3,
  })
);

log

Log is an boolean that turn off and on logs about your cluster.

// Will print logs about cluster
// The default value is true
app.use(
  grupo({
    log: false,
  })
);

Examples

express/connect

var express = require("express");
var grupo = require("grupo");

var app = express();

app.use(grupo(3000));

app.get("/", function (req, res) {
  res.send("hello, world!");
});

app.listen(3000)

vanilla http server

var finalhandler = require("finalhandler");
var http = require("http");
var grupo = require("grupo");

// create "middleware"
var logger = grupo(3000);

http.createServer(function (req, res) {
  var done = finalhandler(req, res);
  logger(req, res, function (err) {
    if (err) return done(err);

    // respond to request
    res.setHeader("content-type", "text/plain");
    res.end("hello, world!");
  });
});

License

MIT

About

Run your application as cluster mode in middleware! ๐Ÿƒ

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages