cluster-requiem
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -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. | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9513
8
250
2