use of fish.payara.arquillian.container.payara.process.CloseableProcess in project Payara by payara.
the class PayaraServerControl method executeAdminCommand.
private void executeAdminCommand(String description, String command, List<String> args, ProcessOutputConsumer consumer) throws LifecycleException {
final List<String> cmd = buildCommand(command, args);
if (config.isOutputToConsole()) {
System.out.println(description + " using command: " + cmd.toString());
}
int result;
try (CloseableProcess process = new CloseableProcess(new ProcessBuilder(cmd).redirectErrorStream(true).start());
ConsoleReader consoleReader = new ConsoleReader(process, consumer)) {
new Thread(consoleReader).start();
result = process.waitFor();
} catch (IOException | InterruptedException e) {
logger.log(SEVERE, description + (e instanceof IOException ? " failed." : " interrupted."), e);
throw new LifecycleException("Unable to execute " + cmd.toString(), e);
}
if (result != 0) {
throw new LifecycleException("Unable to execute " + cmd.toString());
}
}
Aggregations