diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-18 16:08:20 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-18 16:08:20 +0200 |
commit | 6a5f7d47f8d5443cd394eca2b10db8bbe4887a75 (patch) | |
tree | 210a247e6e80840cebeb271742ce529f84e64576 /server | |
parent | 78f1547dfa5a4c87f202fa98d4f89e1cd721b005 (diff) | |
download | sonarqube-6a5f7d47f8d5443cd394eca2b10db8bbe4887a75.tar.gz sonarqube-6a5f7d47f8d5443cd394eca2b10db8bbe4887a75.zip |
SONAR-5408 - reading properties from sonar.properties for child processes
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java index 428d85d42fb..ea9b86a6621 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java @@ -53,6 +53,7 @@ public class ProcessWrapper extends Thread { final int port; final String workDir; + final String javaOpts; final String className; final String[] classPath; final Map<String, String> properties; @@ -66,10 +67,16 @@ public class ProcessWrapper extends Thread { final ProcessMXBean processMXBean; public ProcessWrapper(String workDir, String className, Map<String, String> properties, final String name, String... classPath) { + this(workDir, null, className, properties, name, className); + LOGGER.warn("Creating process '{}' with no JAVA_OPTS", name); + } + + public ProcessWrapper(String workDir, String javaOpts, String className, Map<String, String> properties, final String name, String... classPath) { super(name); this.port = NetworkUtils.freePort(); LOGGER.info("Creating Process for '{}' with workDir: '{}' and monitoring port: {}", name, workDir, port); this.workDir = workDir; + this.javaOpts = javaOpts; this.className = className; this.classPath = classPath; this.properties = properties; @@ -139,14 +146,6 @@ public class ProcessWrapper extends Thread { + separator + "bin" + separator + "java"; } - private String getJavaOptions() { - if (properties.containsKey(Process.JAVA_OPS)) { - return properties.get(Process.JAVA_OPS); - } else { - return null; - } - } - private List<String> getJMXOptions() { return ImmutableList.<String>of( "-Dcom.sun.management.jmxremote", @@ -192,22 +191,14 @@ public class ProcessWrapper extends Thread { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command().add(getJavaCommand()); - String javaOptions = getJavaOptions(); - if (!StringUtils.isEmpty(javaOptions)) { - processBuilder.command().add(getJavaOptions()); + if (!StringUtils.isEmpty(javaOpts)) { + processBuilder.command().add(javaOpts); } processBuilder.command().addAll(getJMXOptions()); processBuilder.command().addAll(getClassPath()); processBuilder.command().add(className); processBuilder.command().add(getPropertyFile()); - //TODO remove once Process uses the temp file generated by getPropertyFile(); - processBuilder.environment().putAll(properties); - - processBuilder.environment().put(Process.SONAR_HOME, workDir); - processBuilder.environment().put(Process.NAME_PROPERTY, this.getName()); - processBuilder.environment().put(Process.PORT_PROPERTY, Integer.toString(port)); - //check that working directory exists. File workDirectory = new File(workDir); if (!workDirectory.exists()) { |