Skip to content

Instantly share code, notes, and snippets.

@thanpolas
Last active December 11, 2015 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thanpolas/4595043 to your computer and use it in GitHub Desktop.
Save thanpolas/4595043 to your computer and use it in GitHub Desktop.
node.js :: Checks if the define process is running
/**
* 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