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 Original file line Diff line number Diff line change
Expand Up @@ -740,13 +740,9 @@ forever.cleanUp = function (cleanLogs, allowManager) {
} }


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


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


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


Expand Down

0 comments on commit c17d004

Please sign in to comment.