Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit b07561caefe347ee2ad2e5fb5eb2319c076d6e8a 1 parent 85374d2
Tomaz Muraus authored
7  CHANGES.md
Source Rendered
... ...
@@ -1,6 +1,13 @@
1 1
 Changes
2 2
 =======
3 3
 
  4
+* 06.05.2012 - v0.6.9:
  5
+
  6
+* Allow user to specify "kill_script" attribute in the process runner
  7
+  dependency file.
  8
+  If this attribute is present, the kill_script is executed instead
  9
+  of sending SIGTERM to the process when stopping it.
  10
+
4 11
 * 18.04.2012 - v0.6.8:
5 12
 
6 13
 * Allow user to pass a comma delimited string with config paths to the
10  lib/process_runner/runner.js
@@ -19,6 +19,7 @@ var fs = require('fs');
19 19
 var path = require('path');
20 20
 var net = require('net');
21 21
 var spawn = require('child_process').spawn;
  22
+var exec = require('child_process').exec;
22 23
 
23 24
 var sprintf = require('sprintf').sprintf;
24 25
 var term = require('terminal');
@@ -153,6 +154,7 @@ ProcessRunner.prototype.verifyConfig = function(config) {
153 154
       cleaned[key]['wait_for'] = value.wait_for || null;
154 155
       cleaned[key]['wait_for_options'] = (value.wait_for) ? value.wait_for_options : {};
155 156
       cleaned[key]['available_for_coverage'] = value.available_for_coverage || false;
  157
+      cleaned[key]['kill_script'] = value.kill_script || null;
156 158
       cleaned[key]['timeout'] = parseInt(value.timeout || DEFAULT_TIMEOUT, 10);
157 159
       cleaned[key]['depends'] = value.depends || [];
158 160
 
@@ -335,6 +337,7 @@ ProcessRunner.prototype._startProcess = function(options, callback) {
335 337
         'name': options.name,
336 338
         'log_file_stream': logFileStream,
337 339
         'available_for_coverage': options.available_for_coverage,
  340
+        'kill_script': options.kill_script,
338 341
         'started_at': util.getUnixTimestamp()
339 342
       };
340 343
 
@@ -411,7 +414,12 @@ ProcessRunner.prototype._stopProcess = function(process, callback) {
411 414
   process.process.stderr.removeAllListeners('data');
412 415
 
413 416
   if (!process.available_for_coverage) {
414  
-    process.process.kill('SIGTERM');
  417
+    if (!process.kill_script) {
  418
+      process.process.kill('SIGTERM');
  419
+    }
  420
+    else {
  421
+      exec(process.kill_script, function() {});
  422
+    }
415 423
   }
416 424
   else {
417 425
     process.process.kill('SIGUSR2')

0 notes on commit b07561c

Please sign in to comment.
Something went wrong with that request. Please try again.