Skip to content

Instantly share code, notes, and snippets.

@vasco3
Created March 25, 2016 17:54
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 vasco3/75b7212326d759778256 to your computer and use it in GitHub Desktop.
Save vasco3/75b7212326d759778256 to your computer and use it in GitHub Desktop.
Trigger initctl processes with NodeJS
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