Search in sources :

Example 1 with ProcessListener

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);
}
Also used : ProcessListener(org.zeroturnaround.exec.listener.ProcessListener) ArrayList(java.util.ArrayList) StartedProcess(org.zeroturnaround.exec.StartedProcess) ProcessExecutor(org.zeroturnaround.exec.ProcessExecutor)

Aggregations

ArrayList (java.util.ArrayList)1 ProcessExecutor (org.zeroturnaround.exec.ProcessExecutor)1 StartedProcess (org.zeroturnaround.exec.StartedProcess)1 ProcessListener (org.zeroturnaround.exec.listener.ProcessListener)1