diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-22 22:56:07 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-09-22 22:56:07 +0200 |
commit | f00cda378e649a87b2b1693db5aaaec37461a481 (patch) | |
tree | eca8da0483f5e877cac3ed31d13e8af0f4703b8e /server/sonar-process-monitor | |
parent | 92c30ccd4cd311dc602c0e1a08fc97c09970a4f6 (diff) | |
download | sonarqube-f00cda378e649a87b2b1693db5aaaec37461a481.tar.gz sonarqube-f00cda378e649a87b2b1693db5aaaec37461a481.zip |
SONAR-4898 add sonar.enableStopCommand property for internal use
Diffstat (limited to 'server/sonar-process-monitor')
3 files changed, 5 insertions, 19 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java index 0f2abc34b16..77a4b607d0d 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java @@ -44,23 +44,18 @@ public class JavaProcessLauncher { ProcessRef launch(JavaCommand command) { Process process = null; try { - // cleanup existing monitor file. Child process creates it when ready. - // TODO fail if impossible to delete + // cleanup existing monitor files ProcessCommands commands = new ProcessCommands(command.getTempDir(), command.getKey()); - commands.prepareMonitor(); + commands.prepare(); ProcessBuilder processBuilder = create(command); LoggerFactory.getLogger(getClass()).info("Launch {}: {}", command.getKey(), StringUtils.join(processBuilder.command(), " ")); - - long startedAt = System.currentTimeMillis(); process = processBuilder.start(); StreamGobbler inputGobbler = new StreamGobbler(process.getInputStream(), command.getKey()); inputGobbler.start(); - ProcessRef ref = new ProcessRef(command.getKey(), commands, process, inputGobbler); - ref.setLaunchedAt(startedAt); - return ref; + return new ProcessRef(command.getKey(), commands, process, inputGobbler); } catch (Exception e) { // just in case 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 45141afdc54..72c96d129ba 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 @@ -137,16 +137,12 @@ public class Monitor { /** * Asks for processes termination and returns without blocking until termination. - * @return true if termination was requested, false if it was already being terminated */ - boolean stopAsync() { - boolean requested = false; + public void stopAsync() { if (lifecycle.tryToMoveTo(State.STOPPING)) { - requested = true; terminator.setProcesses(processes); terminator.start(); } - return requested; } public State getState() { diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java index ca34de55a5b..672fdf6cb6c 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java @@ -30,7 +30,6 @@ class ProcessRef { private final ProcessCommands commands; private final Process process; private final StreamGobbler gobbler; - private long launchedAt; private volatile boolean stopped = false; ProcessRef(String key, ProcessCommands commands, Process process, StreamGobbler gobbler) { @@ -61,7 +60,7 @@ class ProcessRef { if (isStopped()) { throw new MessageException(String.format("%s failed to start", this)); } - ready = commands.wasReadyAfter(launchedAt); + ready = commands.isReady(); try { Thread.sleep(200L); } catch (InterruptedException e) { @@ -70,10 +69,6 @@ class ProcessRef { } } - void setLaunchedAt(long launchedAt) { - this.launchedAt = launchedAt; - } - /** * True if process is physically down */ |