Skip to content

Commit

Permalink
[refactor] Make forever.checkProcess synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki authored and indexzero committed Oct 22, 2011
1 parent f820056 commit c17d004
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,9 @@ forever.cleanUp = function (cleanLogs, allowManager) {
}

function checkProcess(proc, next) {
forever.checkProcess(proc.pid, function (child) {
proc.child = child;
forever.checkProcess(proc.foreverPid, function (manager) {
proc.manager = manager;
cleanProcess(proc, next);
});
});
proc.child = forever.checkProcess(proc.pid);
proc.manager = forever.checkProcess(proc.foreverPid);
cleanProcess(proc, next);
}

if (processes && processes.length > 0) {
Expand Down Expand Up @@ -848,9 +844,9 @@ forever.pidFilePath = function (pidFile) {
// #### @callback {function} Continuation to pass control backto.
// Utility function to check to see if a pid is running
//
forever.checkProcess = function (pid, callback) {
forever.checkProcess = function (pid) {
if (!pid) {
return callback(false);
return false;
}

try {
Expand All @@ -860,10 +856,10 @@ forever.checkProcess = function (pid, callback) {
// only checks if sending a singal to a given process is possible.
//
process.kill(pid, 0);
callback(true);
return true;
}
catch (err) {
callback(false);
return false;
}
};

Expand Down

0 comments on commit c17d004

Please sign in to comment.