Przeglądaj źródła

The server auto-kills when a major error occurs

Gaël Métais 10 lat temu
rodzic
commit
b730249b34
2 zmienionych plików z 17 dodań i 0 usunięć
  1. 10 0
      app/lib/phantomasWrapper.js
  2. 7 0
      app/node_views/launchTest.html

+ 10 - 0
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);
             }

+ 7 - 0
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();