Comparing version 0.2.3 to 0.2.4
@@ -25,2 +25,3 @@ /* | ||
util = require('util'), | ||
net = require('net'), | ||
events = require('events'); | ||
@@ -79,3 +80,3 @@ | ||
else { | ||
createApp.call(null, function (app) { | ||
initApp(function (app) { | ||
master.listen(app, function () { | ||
@@ -95,3 +96,3 @@ if(self.options.ecv) { | ||
else { | ||
createApp.call(null, function (app) { | ||
initApp(function (app) { | ||
app.listen(self.options.port, function () { | ||
@@ -109,4 +110,23 @@ if(self.options.ecv) { | ||
} | ||
function initApp(cb) { | ||
createApp.call(null, function (app) { | ||
// If the port is already occupied, this will exit to prevent node workers from multiple | ||
// 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); | ||
} | ||
}); | ||
server.listen(self.options.port, function() { //'listening' listener | ||
server.close(); | ||
cb(app); | ||
}); | ||
}); | ||
} | ||
} | ||
Cluster.prototype.stop = function () { | ||
@@ -113,0 +133,0 @@ var master = new Process({ |
@@ -163,11 +163,2 @@ /* | ||
); | ||
monitor.on('error', function (e) { | ||
// If the port is already occupied, this will exit to prevent node workers from multiple | ||
// masters hanging around together | ||
if(e.code === 'EADDRINUSE') { | ||
console.log('Address in use ...'); | ||
process.exit(-1); | ||
} | ||
}); | ||
monitor.on('listening', function() { | ||
@@ -174,0 +165,0 @@ misc.ensureDir(process.cwd() + '/pids', true); // Ensure pids dir |
{ | ||
"author": "ql.io", | ||
"name": "cluster2", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -1,2 +0,1 @@ | ||
## What is cluster2 | ||
@@ -8,3 +7,4 @@ | ||
our needs in operationalizing node.js for [ql.io](https://github.com/ql-io/ql.io) at eBay. Built on | ||
node's `cluster`, cluster2 provides several additional capabilities: | ||
node's `cluster`, cluster2 adds several safeguards and utility functions to help support real-world | ||
production scenarios: | ||
@@ -18,2 +18,3 @@ * Scriptable start, shutdown and stop flows | ||
* Events for logging cluster activities | ||
* and more coming soon | ||
@@ -98,3 +99,3 @@ ## Usage | ||
* `ecv`: A validator to validate the runtime health of the app. If found unhealthy, emits a disable | ||
traffic signal at path `/ecv`. | ||
traffic signal at path `/ecv`. ECV stands for "extended content verification". | ||
* `noWorkers`: Defaults to `os.cpus().length`. | ||
@@ -132,2 +133,12 @@ * `timeout`: Idle socket timeout. Automatically ends incoming sockets if found idle for this | ||
<<<<<<< HEAD | ||
Completion of `shutdown()` does not necessarily mean that all worker processes are dead immediately. The workers | ||
may take a while to complete processing of current requests and exit. The `shutdown` flow only | ||
guarantees that the server takes no new connections. | ||
======= | ||
Completion of `shutdown()` does not necessarily mean that all worker processes are dead immediately. | ||
The workers may take a while to complete processing of current requests and exit. The `shutdown()` | ||
flow only guarantees that the server takes no new connections. | ||
>>>>>>> 70b11cd6a93ae49ff959e60d52a5ba91b012690f | ||
## Cluster2 Events | ||
@@ -134,0 +145,0 @@ |
@@ -22,2 +22,2 @@ * <del>Basic cluster</del> | ||
* Traffic in and out - continue connection listening but update ecv | ||
* Raise heartbeats thru logEmitter https://github.scm.corp.ebay.com/qlio/ql.io/issues/74 | ||
* Raise heartbeats thru logEmitter |
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
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
72975
1125
181
4