Comparing version 0.3.1 to 0.3.2
@@ -113,15 +113,22 @@ /* | ||
// masters hanging around together | ||
var server = net.createServer(); | ||
server.on('error', function (e) { | ||
if(e.code === 'EADDRINUSE') { | ||
console.log('Address in use ...'); | ||
process.exit(-1); | ||
} | ||
var ports = _.isArray(self.options.port) ? self.options.port : [self.options.port]; | ||
_.each(ports, function(port) { | ||
exitIfBusyPort(port); | ||
}); | ||
server.listen(self.options.port, function() { //'listening' listener | ||
server.close(); | ||
cb(app); | ||
}); | ||
cb(app); | ||
}); | ||
} | ||
function exitIfBusyPort(port) { | ||
var server = net.createServer(); | ||
server.on('error', function (e) { | ||
if(e.code === 'EADDRINUSE') { | ||
console.log('Address in use ...'); | ||
process.exit(-1); | ||
} | ||
}); | ||
server.listen(port, function() { //'listening' listener | ||
server.close(); | ||
}); | ||
} | ||
} | ||
@@ -128,0 +135,0 @@ |
@@ -85,3 +85,3 @@ /* | ||
npm.load({}, function() { | ||
npm.commands.ls({}, true, function(e, data) { | ||
npm.commands.ls([], true, function(e, data) { | ||
res.writeHead(200, { | ||
@@ -88,0 +88,0 @@ 'Content-Type': 'application/json' |
@@ -69,5 +69,2 @@ /* | ||
} | ||
else if(/worker\./.test(filename)) { | ||
mf = fullname; | ||
} | ||
}); | ||
@@ -124,3 +121,3 @@ }) | ||
this.createWorker = function () { | ||
var worker = cluster.fork(); | ||
var worker = cluster.fork().process; | ||
var self = this; | ||
@@ -193,3 +190,7 @@ fs.writeFileSync(this.options.pids + '/worker.' + worker.pid + '.pid', worker.pid); | ||
var deathWatcher = function (worker) { | ||
var deathWatcher = function (worker, code, signal) { | ||
if(code === 0) { | ||
self.stats.noWorkers--; | ||
return; | ||
} | ||
self.emitter.emit('died', worker.pid); | ||
@@ -203,6 +204,6 @@ self.stats.workersKilled++; | ||
}; | ||
cluster.on('death', deathWatcher); | ||
cluster.on('exit', deathWatcher); | ||
process.on('SIGINT', function() { | ||
cluster.removeListener('death', deathWatcher); | ||
cluster.removeListener('exit', deathWatcher); | ||
self.emitter.emit('SIGINT'); | ||
@@ -217,4 +218,8 @@ }); | ||
}); | ||
process.exit(0); | ||
var internal = setInterval(function() { | ||
if(self.stats.noWorkers === 0) { | ||
clearInterval(internal); | ||
process.exit(0); | ||
} | ||
}, 100); | ||
}); | ||
@@ -309,3 +314,19 @@ | ||
clearInterval(recycle); | ||
process.emit('SIGTERM'); | ||
if(listening) { | ||
try { | ||
app.close(); | ||
} | ||
catch(e) {} | ||
} | ||
self.emitter.emit('SIGTERM', { | ||
pid: process.pid, | ||
type: 'worker' | ||
}); | ||
// Once all pending connections are closed, exit. | ||
var internal = setInterval(function() { | ||
if(conns === 0) { | ||
clearInterval(internal); | ||
process.exit(-1); | ||
} | ||
}, 100); | ||
} | ||
@@ -312,0 +333,0 @@ }, 100); |
@@ -8,3 +8,3 @@ { | ||
"name": "cluster2", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"repository": { | ||
@@ -15,3 +15,3 @@ "type": "git", | ||
"engines": { | ||
"node": ">= 0.6.0" | ||
"node": ">= 0.8.0" | ||
}, | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"underscore": "", | ||
"express": "2.5.9", | ||
"express": "2.5.11", | ||
"ejs": "", | ||
@@ -27,3 +27,3 @@ "npm": "" | ||
"devDependencies": { | ||
"express": "2.5.9", | ||
"express": "2.5.11", | ||
"nodeunit": "", | ||
@@ -30,0 +30,0 @@ "request": "" |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
3
77135
22
1153
+ Addedexpress@2.5.11(transitive)
- Removedexpress@2.5.9(transitive)
Updatedexpress@2.5.11