processExecution.setEnvironmentVariables(startScriptEnv); List<String> arguments = processExecution.getArguments(); if (arguments == null) { arguments = new ArrayList<String>(); processExecution.setArguments(arguments); processExecution.setWorkingDirectory(startScriptFile.getParent()); processExecution.setCaptureOutput(true); processExecution.setWaitForCompletion(MAX_PROCESS_WAIT_TIME); processExecution.setKillOnTimeout(false); processExecution.setWaitForCompletion(waitTime); } else if (waitTime < 0) { processExecution.setWaitForCompletion(0); processExecution.setKillOnTimeout(killOnTimeout);
private ProcessExecution getRpmStart(Configuration pluginConfiguration) { ProcessExecution processExecution; String rpm = getTomcatServiceNum(); if (isWindows()) { processExecution = new ProcessExecution("net"); // disable the executable existence check because it is a command on the supplied PATH processExecution.setCheckExecutableExists(false); processExecution.setArguments(new ArrayList<String>()); processExecution.getArguments().add("start"); processExecution.getArguments().add(rpm); } else { processExecution = new ProcessExecution("service"); // disable the executable existence check because it is a command on the supplied PATH processExecution.setCheckExecutableExists(false); processExecution.setArguments(new ArrayList<String>()); processExecution.getArguments().add(rpm); processExecution.getArguments().add("start"); } Map<String, String> envVars = new LinkedHashMap<String, String>(System.getenv()); processExecution.setEnvironmentVariables(envVars); initProcessExecution(processExecution); return processExecution; }
private void initProcessExecution(ProcessExecution processExecution) { processExecution.setCaptureOutput(true); processExecution.setWaitForCompletion(120000L); // 120 seconds - that should be safe? // TODO: make this configurable processExecution.setKillOnTimeout(false); }
processExecution = new ProcessExecution(executable); processExecution.setArguments(args); processExecution.setEnvironmentVariables(envVars); processExecution.setWorkingDirectory(file.getParent());
private static void applyEnvironmentVars(PropertyList environment, ProcessExecution processExecution) { if (environment != null) { Map<String, String> environmentVariables = processExecution.getEnvironmentVariables(); for (Property prop : environment.getList()) { PropertyMap var = (PropertyMap) prop; environmentVariables.put(var.getSimpleValue("name", null), var.getSimpleValue("value", null)); } processExecution.setEnvironmentVariables(environmentVariables); } }
private void initScriptProcessExecution(ProcessExecution processExecution, File scriptFile) { // For the script to work the current working dir must be set to the script's parent dir processExecution.setWorkingDirectory(scriptFile.getParent()); // Set necessary environment variables setProcessExecutionEnvironment(processExecution, this.serverComponent.getCatalinaHome().getPath(), this.serverComponent.getCatalinaBase().getPath()); initProcessExecution(processExecution); }
private ProcessExecutionResults startNode(File basedir) { if (log.isDebugEnabled()) { log.debug("Starting node at " + basedir); } File binDir = new File(basedir, "bin"); File startScript; SystemInfo systemInfo = SystemInfoFactory.createSystemInfo(); ProcessExecution startScriptExe; if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) { startScript = new File(binDir, "cassandra.bat"); startScriptExe = createProcessExecution(null, startScript); } else { startScript = new File(binDir, "cassandra"); startScriptExe = createProcessExecution(null, startScript); startScriptExe.addArguments(Arrays.asList("-p", "cassandra.pid")); } startScriptExe.setWaitForCompletion(0); ProcessExecutionResults results = systemInfo.executeProcess(startScriptExe); if (log.isDebugEnabled()) { log.debug(startScript + " returned with exit code [" + results.getExitCode() + "]"); } return results; }
private ProcessExecution getScriptStart(Configuration pluginConfiguration) { File startScriptFile = this.serverComponent.getStartScriptPath(); validateScriptFile(startScriptFile, TomcatServerComponent.PLUGIN_CONFIG_START_SCRIPT); String prefix = pluginConfiguration.getSimple(TomcatServerComponent.PLUGIN_CONFIG_SCRIPT_PREFIX) .getStringValue(); ProcessExecution processExecution; // prefix is either null or contains ONLY whitespace characters if (prefix == null || prefix.replaceAll("\\s", "").equals("")) { processExecution = ProcessExecutionUtility.createProcessExecution(startScriptFile); } else { // The process execution should be tied to the process represented as the prefix. If there are any other // tokens in the prefix, consider them arguments to the prefix process. StringTokenizer prefixTokenizer = new StringTokenizer(prefix); String processName = prefixTokenizer.nextToken(); File prefixProcess = new File(processName); processExecution = ProcessExecutionUtility.createProcessExecution(prefixProcess); while (prefixTokenizer.hasMoreTokens()) { String prefixArgument = prefixTokenizer.nextToken(); processExecution.getArguments().add(prefixArgument); } // Assemble the AS start script and its prefixes as one argument to the prefix String startScriptArgument = startScriptFile.getAbsolutePath(); processExecution.getArguments().add(startScriptArgument); } initScriptProcessExecution(processExecution, startScriptFile); return processExecution; }
processExecution = new ProcessExecution(executable); processExecution.setArguments(args); processExecution.setEnvironmentVariables(envVars); processExecution.setWorkingDirectory(file.getParent());
processExecution.setCaptureOutput(true); processExecution.setWaitForCompletion(timeout); processExecution.setKillOnTimeout(true);
Map<String, String> processExecutionEnvironmentVariables = processExecution.getEnvironmentVariables(); if (null == processExecutionEnvironmentVariables) { processExecutionEnvironmentVariables = new LinkedHashMap<String, String>(); processExecution.setEnvironmentVariables(processExecutionEnvironmentVariables);
private ProcessExecution getRpmShutdown() { ProcessExecution processExecution; String rpm = getTomcatServiceNum(); if (isWindows()) { processExecution = new ProcessExecution("net"); // disable the executable existence check because it is a command on the supplied PATH processExecution.setCheckExecutableExists(false); processExecution.setArguments(new ArrayList<String>()); processExecution.getArguments().add("stop"); processExecution.getArguments().add(rpm); } else { processExecution = new ProcessExecution("service"); // disable the executable existence check because it is a command on the supplied PATH processExecution.setCheckExecutableExists(false); processExecution.setArguments(new ArrayList<String>()); processExecution.getArguments().add(rpm); processExecution.getArguments().add("stop"); } Map<String, String> envVars = new LinkedHashMap<String, String>(System.getenv()); log.info("Operation Envs: " + envVars); processExecution.setEnvironmentVariables(envVars); initProcessExecution(processExecution); return processExecution; }