Skip to content

Commit

Permalink
improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shenanigans authored and indexzero committed Oct 30, 2014
1 parent a2320aa commit 6707a40
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function getAllProcesses(callback) {
}

async.map(sockets, getProcess, function (err, processes) {
callback(processes.filter(Boolean));
callback(err, processes.filter(Boolean));
});
});
}
Expand Down Expand Up @@ -516,8 +516,8 @@ forever.stopAll = function (format) {
// Returns the list of all process data managed by forever.
//
forever.list = function (format, callback) {
getAllProcesses(function (processes) {
callback(null, forever.format(format, processes));
getAllProcesses(function (err, processes) {
callback(err, forever.format(format, processes));
});
};

Expand Down Expand Up @@ -592,8 +592,11 @@ forever.tail = function (target, options, callback) {
});
}

getAllProcesses(function (processes) {
if (!processes) {
getAllProcesses(function (err, processes) {
if (err) {
return callback(err);
}
else if (!processes) {
return callback(new Error('Cannot find forever process: ' + target));
}

Expand Down Expand Up @@ -727,8 +730,12 @@ forever.cleanUp = function (cleanLogs, allowManager) {
var emitter = new events.EventEmitter(),
pidPath = forever.config.get('pidPath');

getAllProcesses(function (processes) {
if (cleanLogs) {
getAllProcesses(function (err, processes) {
if (err) {
emitter.emit('error', err);
return;
}
else if (cleanLogs) {
forever.cleanLogsSync(processes);
}

Expand Down

0 comments on commit 6707a40

Please sign in to comment.