use of org.apache.commons.exec.Executor in project ddf by codice.
the class VideoThumbnailPlugin method executeFFmpeg.
private DefaultExecuteResultHandler executeFFmpeg(final CommandLine command, final int timeoutSeconds, final PumpStreamHandler streamHandler) throws IOException {
final ExecuteWatchdog watchdog = new ExecuteWatchdog(timeoutSeconds * 1000L);
final Executor executor = new DefaultExecutor();
final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
if (streamHandler != null) {
executor.setStreamHandler(streamHandler);
}
executor.setWatchdog(watchdog);
executeWithPrivilege(command, executor, resultHandler);
return resultHandler;
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class EngineControl method executeSynch.
/**
* Run a short living engine command where we expect a process failure as the engine invokes <code>System.exit(-1)</code>.
* @param statusCmd
* @return the output of the engine command.
*/
@SuppressWarnings("deprecation")
private String executeSynch(CommandLine statusCmd) {
String engineOutput = null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream, System.err);
Executor executor = createEngineExecutor();
executor.setStreamHandler(streamHandler);
executor.setExitValue(-1);
try {
executor.execute(statusCmd);
} catch (IOException ex) {
// expected!
} finally {
engineOutput = outputStream.toString();
IOUtils.closeQuietly(outputStream);
}
return engineOutput;
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestStartEngine method startEngine_copiedEngine_executable.
@Test
public void startEngine_copiedEngine_executable() throws Exception {
StartTestEngineMojo mojo = rule.getMojo();
mojo.testEngine = TestEngineLocation.COPY_FROM_TEMPLATE;
Executor startedProcess = null;
try {
File cacheEngine = mojo.engineDirectory;
assertFileExecutable(new File(cacheEngine, "elasticsearch/bin/elasticsearch"));
assertFileExecutable(new File(cacheEngine, "elasticsearch/bin/elasticsearch.bat"));
startedProcess = mojo.startEngine();
File engineTarget = mojo.getEngineDir(mojo.project);
assertFileExecutable(new File(engineTarget, "elasticsearch/bin/elasticsearch"));
assertFileExecutable(new File(engineTarget, "elasticsearch/bin/elasticsearch.bat"));
} finally {
kill(startedProcess);
}
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestStartEngine method startEngine_copyEngineToTarget.
@Test
public void startEngine_copyEngineToTarget() throws Exception {
StartTestEngineMojo mojo = rule.getMojo();
Executor startedProcess = null;
try {
mojo.testEngine = TestEngineLocation.COPY_FROM_TEMPLATE;
File engineDirTarget = mojo.getEngineDir(mojo.project);
assertThat(engineDirTarget.toString()).contains("/target/ivyEngine");
assertThat(engineDirTarget).doesNotExist();
startedProcess = mojo.startEngine();
assertThat(engineDirTarget).exists();
} finally {
kill(startedProcess);
}
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestStartEngine method testKillEngineOnVmExit.
@Test
public void testKillEngineOnVmExit() throws Exception {
StartTestEngineMojo mojo = rule.getMojo();
Executor startedProcess = null;
try {
startedProcess = mojo.startEngine();
assertThat(startedProcess.getProcessDestroyer()).isInstanceOf(ShutdownHookProcessDestroyer.class);
ShutdownHookProcessDestroyer jvmShutdownHoock = (ShutdownHookProcessDestroyer) startedProcess.getProcessDestroyer();
assertThat(jvmShutdownHoock.size()).as("One started engine process must be killed on VM end.").isEqualTo(1);
} finally {
kill(startedProcess);
}
}
Aggregations