Last active
December 11, 2015 11:38
-
-
Save thanpolas/4595043 to your computer and use it in GitHub Desktop.
node.js :: Checks if the define process is running
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks if the define process is running | |
* @param {string} process The process. | |
* @param {function(boolean)} The result of the operation. | |
* @return {void} | |
*/ | |
function isRunning(process, cb) { | |
var checkCommand = 'ps x|grep ' + process + '|grep -v grep|awk \'{print $1}\''; | |
var execOptions = {}; | |
exec(checkCommand, execOptions, function( err, stdout ) { | |
if ( err ) { | |
cb(false); | |
return; | |
} | |
if ( stdout ) { | |
cb(true, stdout); | |
return; | |
} | |
cb(false); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment