New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clu

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clu

Run, stop, restart & manage your node cluster.

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by40%
Maintainers
1
Weekly downloads
 
Created
Source

clu

cluster without ster... name might change

A cluster manager inspired by cluster.

Features:

  • built in CLI (optional)
  • zero downtime restarts
  • restarts workers one after another (to prevent performance hit)
  • add or remove workers on the fly
  • uses the node cluster API

Build Status This is still under development

Setup

  1. npm install --save clu
  2. Create a server.js that starts your app.
var clu = require("clu");

clu.createCluster({
	exec: "./app.js",
	workers: 2,
	silent: false,
	silentWorkers: true,
	cli: true
});
// short: clu.createCluster("./app.js");

clu.use(clu.repl());

Start your cluster with node server start or node server & (if you have cli disabled)

Commands

node server --help will output all available commands

These only work if you have the 'cli' option enabled. (server is the file where you call clu.createCluster())

repl

Only works if you clu.use(clu.repl()) Throws you in a repl.

start

Will start the server and throw you back into your terminal.

stop

Will stop all workers and the master.

restart

Respawns all workers one after another.

restart-master

Will restart the master process. (This will cause a downtime!).

scaleup <x>

Start x number of workers

scaledown <x>

Stop x number of workers Use --force to kill them

API

Methods

clu.createCluster(options)

Creates a new cluster. Exec option is required.

** Options **

  • workers - Number of workers, will default to the number of cores
  • silent - Boolean: Makes the master & workers silent (default: false)
  • silentWorkers - Boolean: If true workers output won't be displayed (default: true)
  • cli - Boolean: Enables the CLI. (default: true)
clu.restart(cb)

Respawns all workers one after one and calls the callback after all workers have been respawned.

clu.restartMaster(cb)

Restarts the master process. Calls the callback when all workers disconnected

clu.stop(cb)

Stops the master process and all workers. Callback gets called when all workers disconnect.

clu.stopWorkers(cb)

Stops the all workers but not the master process. Callback gets called when all workers disconnect.

clu.increaseWorkers(num, cb)

Spawns x amount of new workers. Will cb after all new workers are listening.

clu.decreaseWorkers(num, cb)

Stops x amount of workers. Will cb after all workers have disconnected. Will throw if you stop more workers than available or you try to stop all (use clu.stop() for that).

clu.getWorkers(cb)

Calls back with an array of workers.

Plugins

Plugins can be used like this:

var cluAwesome = require("clu-awesome");
clu.use(cluAwesome());
clu.use(clu.repl());

Built in:

  • clu.repl() - a repl interface

Own:

3rd Party: contact me if you create any :)

Licence

MIT

Keywords

FAQs

Package last updated on 06 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc