From b7995949819d15f9c28a9fde36dcc87864419a89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 25 Jan 2016 14:55:01 +0100 Subject: [PATCH] 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 --- .../java/org/sonar/process/monitor/Monitor.java | 16 ++++++++-------- 1 file 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(); } -- 2.39.5