Kill the phantomas subprocess before killing YLT
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var async = require('async');
|
||||
var Q = require('q');
|
||||
var ps = require('ps-node');
|
||||
var debug = require('debug')('ylt:phantomaswrapper');
|
||||
var phantomas = require('phantomas');
|
||||
|
||||
@@ -55,18 +56,34 @@ var PhantomasWrapper = function() {
|
||||
}
|
||||
debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
||||
|
||||
// Kill the application if nothing happens for 10 minutes
|
||||
// Kill the application if nothing happens
|
||||
var phantomasPid;
|
||||
var killer = setTimeout(function() {
|
||||
debug('Killing the app because the test on %s was launched %d seconds ago', task.url, 3*options.timeout);
|
||||
debug('Killing the app because the test on %s was launched %d seconds ago', task.url, 5*options.timeout);
|
||||
// If in server mode, forever will restart the server
|
||||
process.exit(1);
|
||||
}, 3*options.timeout*60*1000);
|
||||
|
||||
// Kill the Phantomas process first
|
||||
if (phantomasPid) {
|
||||
ps.kill(phantomasPid, function(err) {
|
||||
if (err) {
|
||||
debug('Could not kill Phantomas process %s', phantomasPid);
|
||||
}
|
||||
else {
|
||||
debug('Phantomas process %s was correctly killed', phantomasPid);
|
||||
}
|
||||
|
||||
// Then suicide.
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
}, 5*options.timeout*1000);
|
||||
|
||||
// It's time to launch the test!!!
|
||||
var triesNumber = 2;
|
||||
|
||||
async.retry(triesNumber, function(cb) {
|
||||
phantomas(task.url, options, function(err, json, results) {
|
||||
var process = phantomas(task.url, options, function(err, json, results) {
|
||||
debug('Returning from Phantomas');
|
||||
|
||||
// Adding some YellowLabTools errors here
|
||||
@@ -90,6 +107,9 @@ var PhantomasWrapper = function() {
|
||||
|
||||
cb(err, json);
|
||||
});
|
||||
|
||||
phantomasPid = process.pid;
|
||||
|
||||
}, function(err, json) {
|
||||
|
||||
clearTimeout(killer);
|
||||
|
||||
+3
-2
@@ -16,8 +16,9 @@
|
||||
"debug": "~2.1.0",
|
||||
"express": "~4.10.6",
|
||||
"phantomas": "1.8.0",
|
||||
"rimraf": "~2.2.8",
|
||||
"q": "~1.1.2"
|
||||
"ps-node": "0.0.3",
|
||||
"q": "~1.1.2",
|
||||
"rimraf": "~2.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^1.10.0",
|
||||
|
||||
Reference in New Issue
Block a user