aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-25 14:55:01 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-25 14:55:01 +0100
commitb7995949819d15f9c28a9fde36dcc87864419a89 (patch)
tree8d36e099031cdb5cbeaad45ff8c7076c9e1a5e22
parented6f219718bdc9c6435e0cd32e4aa81d558fc302 (diff)
downloadsonarqube-b7995949819d15f9c28a9fde36dcc87864419a89.tar.gz
sonarqube-b7995949819d15f9c28a9fde36dcc87864419a89.zip
SONAR-7168 fix HardStopWatcher support for external restart
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
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
index 5df75054ab9..8f9aa7e59cf 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
@@ -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();
}