diff --git a/lib/forever.js b/lib/forever.js index a8d34f1d..6a368edb 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -93,7 +93,8 @@ function getAllProcesses(callback) { function getProcess(name, next) { var fullPath = path.join(sockPath, name), - socket = new net.Socket({ type: 'unix' }); + socket = new net.Socket({ type: 'unix' }), + data = ''; socket.on('error', function (err) { if (err.code === 'ECONNREFUSED') { @@ -113,8 +114,12 @@ function getAllProcesses(callback) { next(); }); - socket.on('data', function (data) { - var monitors = JSON.parse(data.toString()); + socket.on('data', function (msg) { + data += msg.toString(); + }); + + socket.on('close', function () { + var monitors = JSON.parse(data); results.push.apply(results, monitors.monitors); next(); });