🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

cluster-requiem

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-requiem - npm Package Compare versions

Comparing version

to
1.1.0

lib/linkedlist.js

24

lib/index.js

@@ -5,2 +5,3 @@ var util = require('util');

var cluster = require('cluster');
var LinkedList = require('./linkedlist');

@@ -22,4 +23,4 @@ var Tracker = function() {

this.options = {};
this.sockets = [];
this.trackers = [];
this.sockets = new LinkedList();
this.trackers = new LinkedList();

@@ -51,7 +52,6 @@ };

var self = this;
var item = this.sockets.push(socket);
this.sockets.push(socket);
socket.once('close', function() {
self.sockets.splice(self.sockets.indexOf(socket), 1);
self.sockets.remove(item);
});

@@ -63,7 +63,7 @@ };

var tracker = new Tracker();
var item = this.trackers.push(tracker);
this.trackers.push(tracker);
tracker.once('done', function() {
self.trackers.splice(self.trackers.indexOf(tracker), 1);
self.trackers.remove(item);
});

@@ -142,4 +142,4 @@

Requiem.prototype._closeAllSockets = function(cb) {
async.each(this.sockets, function(socket, cb) {
socket.close(function() {
this.sockets.iterateAsync(function(socket, cb) {
socket.data.close(function() {
cb();

@@ -151,4 +151,4 @@ });

Requiem.prototype._waitAllTrackers = function(cb) {
async.each(this.trackers, function(tracker, cb) {
tracker.once('done', function() {
this.trackers.iterateAsync(function(tracker, cb) {
tracker.data.once('done', function() {
cb();

@@ -155,0 +155,0 @@ });

{
"name": "cluster-requiem",
"version": "1.0.0",
"version": "1.1.0",
"description": "high availability enhacements for clustering",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -23,3 +23,3 @@ cluster-requiem

var cluster = require('cluster');
var requiem = require('./lib');
var requiem = require('cluster-requiem');

@@ -51,3 +51,3 @@ if (cluster.isMaster) {

req.writeHead(200);
req.write('Hello world!');
req.end('Hello world!');
});

@@ -66,4 +66,4 @@

Note: You need to track server sockets in case of a graceful shutdown(PM2 for instance, sends the 'shutdown' event before trying to kill the process). If you don't do this the server will stil receive connections while it waits for all trackers to finish.
Under high load this will potentially lead the server to never close, making PM2 kill long standing jobs as it can't handle they.
> Note: You need to track server sockets in case of a graceful shutdown(PM2 for instance, sends the 'shutdown' event before trying to kill the process). If you don't do this the server will stil receive connections while it waits for all trackers to finish.
> Under high load this will potentially lead the server to never close, making PM2 kill long standing jobs as it can't handle they.