]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7168 fix HardStopWatcher support for external restart
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 25 Jan 2016 13:55:01 +0000 (14:55 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 25 Jan 2016 13:55:01 +0000 (14:55 +0100)
when SQ instance is restarted by another process (eg. orchestrator) which does not clean the temp directory before restarting, the HardStopWatcher of the newly started SQ will detect the stop flag targeted at the previous SQ and immediatly shutdown the App JVM but let the two child JVM process up
to avoid this, the HardStopWatcher is now created only after the temp directory has been reset by the App process

server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java

index 5df75054ab98e3c16f1c1e81403767479bebe28f..8f9aa7e59cf50621e8e30f435bf28d26257e1b8a 100644 (file)
@@ -92,16 +92,10 @@ public class Monitor {
     // intercepts CTRL-C
     Runtime.getRuntime().addShutdownHook(shutdownHook);
 
-    // start watching for stop requested by other process (eg. orchestrator) if enabled
-    if (watchForHardStop) {
-      this.hardStopWatcher = new HardStopWatcherThread();
-      this.hardStopWatcher.start();
-    }
-
     // start watching for restart requested by child process
-    this.restartWatcher.start();
+    restartWatcher.start();
 
-    this.javaCommands = commands;
+    javaCommands = commands;
     startProcesses();
   }
 
@@ -110,6 +104,12 @@ public class Monitor {
     if (lifecycle.tryToMoveTo(State.STARTING)) {
       resetFileSystem();
 
+      // start watching for stop requested by other process (eg. orchestrator) if enabled and not started yet
+      if (watchForHardStop && hardStopWatcher == null) {
+        hardStopWatcher = new HardStopWatcherThread();
+        hardStopWatcher.start();
+      }
+
       startAndMonitorProcesses();
       stopIfAnyProcessDidNotStart();
     }