modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java | 22 +++++++--- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 6 ++ modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java | 12 ----- modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 1 4 files changed, 24 insertions(+), 17 deletions(-)
New commits: commit 1e48ab86c6423839d8693894aab79fd8bb8c60de Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Apr 27 11:50:08 2012 -0400
- Remove JAVA_OPTS from AS5 and AS7 startScriptEnv discovery as it will end up hiding changes to run.conf, which will likely be the preferred mechanism for setting the java options. It can still be added manually to the connection property if desired. - Also, ignore the discovered PATH and set to a minimal PATH required for startup; "/bin:/usr/bin" for linux and, lazily set using SYSTEMROOT env var, "%SYSTEMROOT%\system32:%SYSTEMROOT%" for Windows. This considerably shortens the PATH length, avoiding LongString limits and unnecessary entries, while still providing a predictable PATH for restart.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java index 3209557..819e1e1 100644 --- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java +++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java @@ -43,11 +43,13 @@ import org.rhq.core.system.ProcessInfo; */ public class ServerStartScriptDiscoveryUtility {
+ // Generic OS-level PATH setting for LINUX. For Windows the PATH must be generated when we have + // the system env vars. It will be of the form %SystemRoot%\system32;%SystemRoot%; + private static final String CORE_ENV_VAR_PATH_LINUX = "/bin:/usr/bin"; + // Generic OS-level env vars that should be in every process's environment. - private static final Set<String> CORE_ENV_VAR_NAME_INCLUDES = new HashSet<String>(Arrays.asList( - "PATH", - "LD_LIBRARY_PATH" - )); + private static final Set<String> CORE_ENV_VAR_NAME_INCLUDES = new HashSet<String>(Arrays.asList("PATH", + "LD_LIBRARY_PATH")); static { if (File.separatorChar == '\') { CORE_ENV_VAR_NAME_INCLUDES.add("OS"); // many batch files use this to figure out if the OS type is NT or 9x @@ -55,7 +57,6 @@ public class ServerStartScriptDiscoveryUtility { } }
- private ServerStartScriptDiscoveryUtility() { }
@@ -169,6 +170,17 @@ public class ServerStartScriptDiscoveryUtility { startScriptEnv.put(envVarName, envVarValue); } } + + // Add the fixed PATH + if (File.separatorChar == '\') { + String systemRoot = processEnvVars.get("SYSTEMROOT"); + systemRoot = (systemRoot == null) ? "C:\Windows" : systemRoot; + String path = systemRoot + "\system32;" + systemRoot; + startScriptEnv.put("PATH", path); + } else { + startScriptEnv.put("PATH", CORE_ENV_VAR_PATH_LINUX); + } + return startScriptEnv; }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java index d333463..31c6ab3 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java @@ -131,8 +131,12 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom private static final Set<CommandLineOption> START_SCRIPT_OPTION_EXCLUDES = new HashSet<CommandLineOption>();
static { + // Note that JAVA_OPTS is not included on purpose. If present the setting will override that + // which is set in run.conf or possibly in a custom script. We opt to let run.conf provide the setting + // as that is quite likely what users will expect. JAVA_OPTS can be added manually to the + // startScriptEnv settings at which time it would provide an override. Not discovering JAVA_OPTS also + // avoids issues with duplicate settings, due to manipulations made to it by run.conf. START_SCRIPT_ENV_VAR_NAMES.addAll(Arrays.asList( // - "JAVA_OPTS", // "JAVA_HOME", // "JAVA", // "JAVAC_JAR", // diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java index d28cfb1..7fe7f5f 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java @@ -87,7 +87,6 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent "PROFILER", // "JAVA_HOME", // "JAVA", // - "JAVA_OPTS", // "PRESERVE_JAVA_OPTS", // "PROCESS_CONTROLLER_JAVA_OPTS", // "HOST_CONTROLLER_JAVA_OPTS", //
commit 24fc319f79585970163ff8aade0ac8a17c23b75a Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Apr 26 12:21:42 2012 -0400
trivial - remove some dev logging
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java index f98bf19..e439250 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java @@ -75,7 +75,6 @@ public class JBossInstanceInfo { String[] args = this.processInfo.getCommandLine();
Map<String, String> envVars = this.processInfo.getEnvironmentVariables(); - printEnvVars(envVars);
for (i = 0; i < args.length; i++) { if (args[i].equals(JBOSS_MAIN_CLASS_NAME)) { @@ -318,20 +317,13 @@ public class JBossInstanceInfo { } }
- private void printEnvVars(Map<String, String> envVars) { - log.info("******** Env Vars=" + envVars); - } - private void printSysProps(String[] commandLine) { - if (null != commandLine) { - log.info("******** commandLine=" + Arrays.toString(commandLine)); - } - //if (log.isDebugEnabled()) { + if (log.isDebugEnabled()) { printSysProp(JBossProperties.HOME_DIR); printSysProp(JBossProperties.SERVER_HOME_DIR); printSysProp(JBossProperties.SERVER_NAME); printSysProp(JBossProperties.BIND_ADDRESS); - //} + } }
private void printSysProp(String name) {
rhq-commits@lists.fedorahosted.org