proteus-cluster
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -159,7 +159,13 @@ /** | ||
var workerIds = Object.keys(cluster.workers); | ||
var workerResults = []; | ||
var cmd = message && message.cmd; | ||
if (!cmd) { | ||
sendMessage(message); | ||
res.statusCode = 200; | ||
return res.end('OK'); | ||
res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
for (var i = 0; i < workerIds.length; i++) { | ||
workerResults.push('OK'); | ||
} | ||
return res.end(JSON.stringify(workerResults)); | ||
} | ||
@@ -172,3 +178,2 @@ | ||
var workerIds = Object.keys(cluster.workers); | ||
addMessageListener(cmd, function(msg, worker) { | ||
@@ -179,8 +184,10 @@ workerIds = workerIds.filter(function(v) { | ||
workerResults.push(msg && msg.msg || ''); | ||
if (workerIds.length <= 0) { | ||
clearTimeout(timer); | ||
removeMessageListener(cmd); | ||
res.statusCode = 200; | ||
res.end('OK'); | ||
} | ||
res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
res.end(JSON.stringify(workerResults)); | ||
} | ||
}); | ||
@@ -187,0 +194,0 @@ |
{ | ||
"name": "proteus-cluster", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "start": "node app", |
@@ -112,3 +112,5 @@ 'use strict'; | ||
res.on('data', function(chunk) { | ||
expect('OK').to.eql(chunk); | ||
var result = JSON.parse(chunk); | ||
expect(result).to.be.an('array'); | ||
expect(result.length).to.eql(conf.worker); | ||
}); | ||
@@ -115,0 +117,0 @@ res.on('end', function() { |
25339
561