Permalink
Browse files

llow user to specify "kill_script" attribute in the process runner de…

…pendency

file.

If this attribute is present, the kill_script is executed instead of sending
SIGTERM to the process when stopping it.

This is useful if you start a process which forks itself.
  • Loading branch information...
Kami committed May 6, 2012
1 parent 85374d2 commit b07561caefe347ee2ad2e5fb5eb2319c076d6e8a
Showing with 16 additions and 1 deletion.
  1. +7 −0 CHANGES.md
  2. +9 −1 lib/process_runner/runner.js
View
@@ -1,6 +1,13 @@
Changes
=======
+* 06.05.2012 - v0.6.9:
+
+* Allow user to specify "kill_script" attribute in the process runner
+ dependency file.
+ If this attribute is present, the kill_script is executed instead
+ of sending SIGTERM to the process when stopping it.
+
* 18.04.2012 - v0.6.8:
* Allow user to pass a comma delimited string with config paths to the
@@ -19,6 +19,7 @@ var fs = require('fs');
var path = require('path');
var net = require('net');
var spawn = require('child_process').spawn;
+var exec = require('child_process').exec;
var sprintf = require('sprintf').sprintf;
var term = require('terminal');
@@ -153,6 +154,7 @@ ProcessRunner.prototype.verifyConfig = function(config) {
cleaned[key]['wait_for'] = value.wait_for || null;
cleaned[key]['wait_for_options'] = (value.wait_for) ? value.wait_for_options : {};
cleaned[key]['available_for_coverage'] = value.available_for_coverage || false;
+ cleaned[key]['kill_script'] = value.kill_script || null;
cleaned[key]['timeout'] = parseInt(value.timeout || DEFAULT_TIMEOUT, 10);
cleaned[key]['depends'] = value.depends || [];
@@ -335,6 +337,7 @@ ProcessRunner.prototype._startProcess = function(options, callback) {
'name': options.name,
'log_file_stream': logFileStream,
'available_for_coverage': options.available_for_coverage,
+ 'kill_script': options.kill_script,
'started_at': util.getUnixTimestamp()
};
@@ -411,7 +414,12 @@ ProcessRunner.prototype._stopProcess = function(process, callback) {
process.process.stderr.removeAllListeners('data');
if (!process.available_for_coverage) {
- process.process.kill('SIGTERM');
+ if (!process.kill_script) {
+ process.process.kill('SIGTERM');
+ }
+ else {
+ exec(process.kill_script, function() {});
+ }
}
else {
process.process.kill('SIGUSR2')

0 comments on commit b07561c

Please sign in to comment.