From b730249b34517dfcf843d5af86e7871644fadcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 5 Sep 2014 19:04:25 +0200 Subject: [PATCH] The server auto-kills when a major error occurs --- app/lib/phantomasWrapper.js | 10 ++++++++++ app/node_views/launchTest.html | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/app/lib/phantomasWrapper.js b/app/lib/phantomasWrapper.js index 3c87fd4..aac2fb5 100644 --- a/app/lib/phantomasWrapper.js +++ b/app/lib/phantomasWrapper.js @@ -69,6 +69,13 @@ var PhantomasWrapper = function() { } console.log('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose'); + // Kill the application if nothing happens for 10 minutes + var killer = setTimeout(function() { + console.log('Killing the server because the test ' + task.testId + ' on ' + task.url + ' was launched 10 minutes ago'); + // Forever will restart the server + process.exit(1); + }, 600000); + // It's time to launch the test!!! var triesNumber = 3; @@ -98,6 +105,9 @@ var PhantomasWrapper = function() { cb(err, {json: json, results: results}); }); }, function(err, data) { + + clearTimeout(killer); + if (err) { console.log('All ' + triesNumber + ' attemps failed for test id ' + task.testId); } diff --git a/app/node_views/launchTest.html b/app/node_views/launchTest.html index 4fb86dd..9d31ffc 100644 --- a/app/node_views/launchTest.html +++ b/app/node_views/launchTest.html @@ -62,6 +62,13 @@ document.body.className = ''; }); + socket.on('reconnect_error', function() { + statusElement.innerHTML = "Server reboot. Please start a new test." + + // Stop the spinner + document.body.className = ''; + }); + askStatus();