npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clusterjs

v0.7.1

Published

Clusterify your NodeJS applications and deploy without downtimes. Just like that.

Downloads

22

Readme

ClusterJS

An handy tool for your node servers and 0 downtime needs.

ClusterJS will take your app and spawn it in a node-cluster with as many workers you want.

You can reload the whole cluster sending a simple signal: ClusterJS will go through all your workers, reloading them one by one.

~/projects/clusterjs (master ✔) ᐅ clusterjs
Cluster.js help:

Usage: clusterjs [path to app] [options]

Options:
 --workers	 Defines how many workers we should launch (Default: CPU count)
 --reloadon	 On Which signal will the cluster be reloaded (Default: SIGUSR2)

Installation

It is recommended to install the package globally:

npm install -g clusterjs

Usage

Suppose you have an app running on an app.js file, you can simply decide to start it with clusterjs:

clusterjs app.js

This will start a cluster of as many apps as CPU cores you have on your machine; to change the number of workers, simply specify it when launching the cluster:

clusterjs app.js --workers 5

WARNING if your path contains a symlink, clusterjs will need the full path to your app

clusterjs /path/to/your/app.js

You can reload the cluster, achieving zero-downtime deployments by issuing a SIGUSR2 command to the master process:

~/projects/clusterjs (master ✔) ᐅ ps aux | grep cluster.js
29571  2.0  0.1 659236 10440 pts/4    Sl+  23:21   0:00 node ./bin/cluster.js test/testApp/app.js
29573  1.5  0.1 656160  8564 pts/4    Sl+  23:21   0:00 /home/local/bin/node /home/projects/clusterjs/bin/cluster.js test/testApp/app.js
29574  2.0  0.1 656160  8564 pts/4    Sl+  23:21   0:00 /home/local/bin/node /home/projects/clusterjs/bin/cluster.js test/testApp/app.js
29576  1.5  0.1 656160  8564 pts/4    Sl+  23:21   0:00 /home/local/bin/node /home/projects/clusterjs/bin/cluster.js test/testApp/app.js
29577  1.5  0.1 656160  8564 pts/4    Sl+  23:21   0:00 /home/local/bin/node /home/projects/clusterjs/bin/cluster.js test/testApp/app.js
29582  0.0  0.0  13636   984 pts/5    S+   23:21   0:00 grep cluster.js

~/projects/clusterjs (master ✔) ᐅ kill -SIGUSR2 29571

This will gracefully reload your cluster, updating the app without any downtime.

You can also customize the signal used to reload the cluster:

clusterjs app.js --workers 5 --reloadon SIGUSR2

If you want to actually shutdown the app, simply issue a SIGTERM or a SIGQUIT (ie. kill 29571).

As a module

You can also use cluster.js as a module in your userland code by simply requiring it:

var clusterjs = require('clusterjs');

cluster('app.js', 5, 'SIGUSR2');

Have a closer look

You can use the simple dummy server included in the tests/testApp directory if you need to experiment:

git clone [email protected]:namshi/clusterjs.git

cd clusterjs

./bin/cluster.js test/testApp/app.js

Thanks to

Well, the biggest effort was made by Jonathan Warner who explained how easily you could achieve ZDD with node.

We polished the code a bit as we found out that it had some glitches but the main idea remains the same (so yeah, thanks Jax!).

License

ClusterJS is released under the MIT license.