Permalink
Browse files

[fix] kill all processes associated with the solenoid user

  • Loading branch information...
jcrugzz committed Mar 14, 2014
1 parent f802ed6 commit 22bf54c6de8f1ce9bc43c6fa328e9c981a443ed0
Showing with 29 additions and 10 deletions.
  1. +29 −10 lib/solenoid.js
View
@@ -121,31 +121,50 @@ exports.stop = function (options, callback) {
},
function removePid(next) {
fs.unlink(options.pidFile, next.bind(null, null));
+ },
+ function blanketKill(next) {
+ killNet(options, next);
}
], callback);
});
});
};
+var killNet = function killNet (options, callback) {
+ var logger = options.logger;
+
+ var args = ['pkill', '-9', '-U', 'solenoid'];
+
+ runChild(logger, args, callback);
+
+};
+
+//
+// Spawn a child process and output the results
+//
+var runChild = function runChild (logger, args, callback) {
+ var command = args.shift(),
+ child = spawn(command, args);
+
+ child.stdout.on('data', function (d) { logger.info('' + d) });
+ child.stderr.on('data', function (d) { logger.info('' + d) });
+ child.on('exit', callback.bind(null, null));
+};
+
var clean = exports.clean = function clean(options, callback) {
var commands = [
- ['pkill', '-9', 'aeternum'],
- ['pkill', 'forza'],
['rm', '-rf', options.pidFile || path.join(process.env.HOME, 'app.pid')],
['rm', '-rf', options.runDir || ('/' + path.join('opt', 'run'))]
];
var logger = options.logger;
logger.info('Cleaning ' + options.runDir);
- async.forEachSeries(commands, function (args, next) {
- var command = args.shift(),
- child = spawn(command, args);
-
- child.stdout.on('data', function (d) { logger.info('' + d) });
- child.stderr.on('data', function (d) { logger.info('' + d) });
- child.on('exit', next.bind(null, null));
- }, callback);
+ async.forEachSeries(
+ commands,
+ runChild.bind(null, logger),
+ killNet.bind(null, options, callback)
+ );
};
var fetch = exports.fetch = function fetch(options, callback) {

0 comments on commit 22bf54c

Please sign in to comment.