use of org.zeroturnaround.exec.listener.ProcessListener in project ninja by ninjaframework.
the class RunClassInSeparateJvmMachine method buildProcessExecutor.
ProcessExecutor buildProcessExecutor() {
List<String> commandLine = new ArrayList<>();
String javaHome = System.getProperty("java.home");
String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
commandLine.add(javaBin);
commandLine.addAll(jvmArguments);
commandLine.add("-cp");
commandLine.add(classpath);
commandLine.add(classNameWithMainToRun);
// not redirecting error stream used for unit tests
return new ProcessExecutor(commandLine).directory(mavenBaseDir).destroyOnExit().addListener(new ProcessListener() {
@Override
public void afterStop(Process process) {
if (!restarting.get()) {
log.error("JVM process for {} terminated (next file change will attempt to restart it)", name);
}
}
}).redirectErrorStream(true).redirectOutput(this.output);
}
Aggregations