use of org.apache.commons.exec.ShutdownHookProcessDestroyer in project camel by apache.
the class DefaultExecCommandExecutor method prepareDefaultExecutor.
protected DefaultExecutor prepareDefaultExecutor(ExecCommand execCommand) {
DefaultExecutor executor = new ExecDefaultExecutor();
executor.setExitValues(null);
if (execCommand.getWorkingDir() != null) {
executor.setWorkingDirectory(new File(execCommand.getWorkingDir()).getAbsoluteFile());
}
if (execCommand.getTimeout() != ExecEndpoint.NO_TIMEOUT) {
executor.setWatchdog(new ExecuteWatchdog(execCommand.getTimeout()));
}
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
return executor;
}
use of org.apache.commons.exec.ShutdownHookProcessDestroyer in project frontend-maven-plugin by eirslett.
the class ProcessExecutor method createExecutor.
private Executor createExecutor(File workingDirectory, long timeoutInSeconds) {
DefaultExecutor executor = new DefaultExecutor();
executor.setWorkingDirectory(workingDirectory);
// Fixes #41
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
if (timeoutInSeconds > 0) {
executor.setWatchdog(new ExecuteWatchdog(timeoutInSeconds * 1000));
}
return executor;
}
use of org.apache.commons.exec.ShutdownHookProcessDestroyer in project camel by apache.
the class ProvokeExceptionExecCommandExecutor method prepareDefaultExecutor.
@Override
protected DefaultExecutor prepareDefaultExecutor(ExecCommand execCommand) {
DefaultExecutor executor = new DefaultExecutorMock();
executor.setExitValues(null);
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
return executor;
}
use of org.apache.commons.exec.ShutdownHookProcessDestroyer in project stanbol by apache.
the class JarExecutor method start.
/**
* Start the jar if not done yet, and setup runtime hook to stop it.
*/
public void start() throws Exception {
final ExecuteResultHandler h = new ExecuteResultHandler() {
@Override
public void onProcessFailed(ExecuteException ex) {
log.error("Process execution failed:" + ex, ex);
}
@Override
public void onProcessComplete(int result) {
log.info("Process execution complete, exit code=" + result);
}
};
final String vmOptions = System.getProperty("jar.executor.vm.options");
final Executor e = new DefaultExecutor();
if (this.workingDirectory != null) {
e.setWorkingDirectory(this.workingDirectory);
}
final CommandLine cl = new CommandLine(javaExecutable);
if (vmOptions != null && vmOptions.length() > 0) {
// not the case for common usage patterns
for (String option : StringUtils.split(vmOptions, " ")) {
cl.addArgument(option);
}
}
cl.addArgument("-jar");
cl.addArgument(jarToExecute.getAbsolutePath());
cl.addArgument("-p");
cl.addArgument(String.valueOf(serverPort));
log.info("Executing " + cl);
e.setStreamHandler(new PumpStreamHandler());
e.setProcessDestroyer(new ShutdownHookProcessDestroyer());
e.execute(cl, h);
}
Aggregations