Created
March 25, 2016 17:54
-
-
Save vasco3/75b7212326d759778256 to your computer and use it in GitHub Desktop.
Trigger initctl processes with NodeJS
This file contains hidden or 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
var exec = require('child_process').exec; | |
var child; | |
var listCmd = 'initctl list | ag ' + process.argv[2]; | |
exec(listCmd, function (error, stdout, stderr) { | |
if (error !== null) { console.log('exec listCmd error', error); } | |
var rows = stdout.split('\n'); | |
rows.forEach(function (row) { | |
var service = row.split(' ')[0]; | |
if (service) { | |
var initctlCmd = 'initctl ' + process.argv[3] + ' ' + service; | |
console.log(initctlCmd) | |
exec(initctlCmd, function (error, stdout, stderr) { | |
if (error !== null) { console.log('exec initctlCmd error', error); } | |
console.log(stdout); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment