]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5237 - Fixed exit of runner when TC Fails to load
authorStephane Gamard <stephane.gamard@searchbox.com>
Tue, 29 Jul 2014 15:01:58 +0000 (17:01 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Tue, 29 Jul 2014 15:01:58 +0000 (17:01 +0200)
server/sonar-process/src/main/java/org/sonar/process/Monitor.java
server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
server/sonar-server/src/main/java/org/sonar/server/app/ServerProcess.java

index 75fd0ef8200735217071692d31f20f191704b15e..7f11bf3a3780350cd164920cc5dbd86103f87438 100644 (file)
@@ -55,7 +55,6 @@ public class Monitor extends Thread {
   public void registerProcess(ProcessWrapper processWrapper) {
     processes.add(processWrapper);
     pings.put(processWrapper.getName(), System.currentTimeMillis());
-    processWrapper.start();
     for (int i = 0; i < 10; i++) {
       if (processWrapper.getProcessMXBean() == null || !processWrapper.getProcessMXBean().isReady()) {
         try {
@@ -65,6 +64,7 @@ public class Monitor extends Thread {
         }
       }
     }
+    processWrapper.start();
   }
 
   private class ProcessWatch implements Runnable {
@@ -78,6 +78,7 @@ public class Monitor extends Thread {
           }
         } catch (Exception e) {
           LOGGER.error("Error while pinging {}", process.getName(), e);
+          terminate();
         }
       }
     }
index 80f444dd6deafab1424888ac7f8b5d9c8ac8ce2c..fe4be0416823bf9c829821e4782d4e227e973ac8 100644 (file)
@@ -70,9 +70,6 @@ class EmbeddedTomcat {
       tomcat.getServer().await();
     } catch (Exception e) {
       throw new IllegalStateException("Fail to start web server", e);
-    } finally {
-      // Shutdown command received
-      stop();
     }
   }
 
index 6af087308350c6ea17d244e7b6d9af02865d3c17..6651f5355d39ea60a648c5f1c9eef402668f9fe9 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.app;
 
+import org.slf4j.LoggerFactory;
 import org.sonar.process.ConfigurationUtils;
 import org.sonar.process.Props;
 
@@ -33,7 +34,13 @@ public class ServerProcess extends org.sonar.process.Process {
 
   @Override
   public void onStart() {
-    tomcat.start();
+    try {
+      tomcat.start();
+    } catch (Exception e) {
+      LoggerFactory.getLogger(getClass()).error("TC error", e);
+    } finally {
+      terminate();
+    }
   }
 
   @Override