use of org.openntf.openliberty.domino.util.StreamRedirector in project openliberty-domino by OpenNTF.
the class LibertyServerInstance method sendCommand.
private Process sendCommand(Path path, Path javaHome, String command, Object... args) {
try {
// $NON-NLS-1$
Path serverScript = path.resolve("bin").resolve(serverFile);
List<String> commands = new ArrayList<>();
commands.add(serverScript.toString());
commands.add(command);
for (Object arg : args) {
commands.add(StringUtil.toString(arg));
}
ProcessBuilder pb = new ProcessBuilder().command(commands);
Map<String, String> env = pb.environment();
// $NON-NLS-1$
env.put("JAVA_HOME", javaHome.toString());
// $NON-NLS-1$
String sysPath = System.getenv("PATH");
sysPath += File.pathSeparator + dominoProgramDirectory;
// $NON-NLS-1$
env.put("PATH", sysPath);
// $NON-NLS-1$
env.put("Domino_HTTP", getServerBase());
if (log.isLoggable(Level.FINE)) {
// $NON-NLS-1$
OpenLibertyLog.getLog().fine(format(Messages.getString("OpenLibertyRuntime.executingCommand"), pb.command()));
}
Process process = pb.start();
subprocesses.add(process);
DominoThreadFactory.getExecutor().submit(new StreamRedirector(process.getInputStream()));
DominoThreadFactory.getExecutor().submit(new StreamRedirector(process.getErrorStream()));
return process;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations