executor.setWatchdog(watchdog);
ExecuteStreamHandler streamHandler = new PumpStreamHandler(outStream, errStream); executor.setStreamHandler(streamHandler); executor.setWatchdog(watchDog); int retValue = executor.execute(cli, ENVIRONMENT_MAP); if (retValue != 0) {
/** * Create {@link org.apache.commons.exec.Executor} with infinite timeout watchdog * * @return created executor */ public static Executor createExecutor() { ExecuteWatchdog watchdog = new ExecuteWatchdog(INFINITE_TIMEOUT); Executor executor = new DefaultExecutor(); executor.setExitValue(1); executor.setWatchdog(watchdog); return executor; }
executor.setWatchdog(watchdog);
public void execute(CommandLine cmd, @Nullable File workingDirectory) throws InterruptedException, IOException { LOG.info("executing command {}", cmd.toString()); final ExecuteWatchdog watchdog = new ExecuteWatchdog(60 * 1000); final Executor executor = new org.apache.commons.exec.DefaultExecutor(); executor.setWatchdog(watchdog); if (workingDirectory != null) { executor.setWorkingDirectory(workingDirectory); } LOG.debug("workdir: {}", executor.getWorkingDirectory()); final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream err = new ByteArrayOutputStream(); executor.setStreamHandler(new PumpStreamHandler(out, err)); executor.execute(cmd, resultHandler); resultHandler.waitFor(); final int exitCode = resultHandler.getExitValue(); if (out.size() > 0) { LOG.info(out.toString()); } if (exitCode != 0) { throw new IOException(err.size() == 0 ? "command '" + cmd + "' didn't succeed" : err.toString()); } } }
/** * Get an Executor that will run in the given directory with a watchdog set * for the timeout. * * @param workDir * The working directory for the process * @return An executor. */ protected Executor getExecutor(File workDir) { Executor executor= new DefaultExecutor(); executor.setWorkingDirectory(workDir); if (timeout > 0) { ExecuteWatchdog watchdog= new ExecuteWatchdog(timeout); executor.setWatchdog(watchdog); } return executor; }
executor.setWatchdog(watchdog); executor.setWorkingDirectory(pugTemp); executor.execute(cmdLine, resultHandler);
executor.setWatchdog(watchdog); try { executor.execute(commandLine, env, resultHandler);
executor.setWatchdog(watchdog);
executor.setWatchdog(watchdog);
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer()); ExecuteWatchdog watchDog = new ExecuteWatchdog(watchdogTimeout); executor.setWatchdog(watchDog); if (StringUtils.isBlank(standardInText))
private static void internalExecute(CommandLine cmdLine, OutputStream outputStream, File workingDirectory) throws IOException { Executor executor = getExecutor(); ExecuteWatchdog watchdog = getExecuteWatchdog(); executor.setWatchdog(watchdog); if (workingDirectory != null) { executor.setWorkingDirectory(workingDirectory); } // set allowed exit values (0 is actually the default) executor.setExitValue(0); PumpStreamHandler psh = new PumpStreamHandler(outputStream); executor.setStreamHandler(psh); executor.execute(cmdLine); if (watchdog.killedProcess()) { throw new ExecuteException(String.format("Watchdog killed Sencha Cmd process after %s ms.", MAX_EXECUTION_TIME), 0); } }
executor.setWatchdog(watchdog);
ExecuteStreamHandler streamHandler = new PumpStreamHandler(outStream, errStream); executor.setStreamHandler(streamHandler); executor.setWatchdog(watchDog); int retValue = executor.execute(cli, ENVIRONMENT_MAP); if (retValue != 0) {
executor.setWatchdog(watchdog); executor.execute(cmdLine, resultHandler);
executor.setWatchdog(watchdog); executor.setWorkingDirectory(pugTemp); executor.execute(cmdLine, resultHandler);
executor.setWatchdog(watchdog);
Executor executor = new DefaultExecutor(); executor.setExitValue(1); executor.setWatchdog(watchdog); executor.setStreamHandler(streamHandler); try {
private static Executor createExecutor(LineConsumer consoleLogHandler, CommandLine command, File projectRoot, ExecuteWatchdog watchDog) { Executor executor = new DefaultExecutor(); executor.setWorkingDirectory(projectRoot); executor.setWatchdog(watchDog); executor.setStreamHandler(new PumpStreamHandler(new WriterOutputStream(new WriterToOutputBridge(consoleLogHandler)))); consoleLogHandler.consumeLine(fullPath(executor.getWorkingDirectory()) + "> " + String.join(" ", command.toStrings()) + LINE_SEPARATOR); return executor; }
executor.setWatchdog(new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT));