public static int executeCommand(String command, ExecuteWatchdog watchdog, Map<String, String> env) { return executeCommand(command, watchdog, null, null, null, env); }
this.pid = ProcessUtils.getPid(process); } catch (Throwable e) { log.error("While run swarm executable for {} " , getProcessInfo(), e);
private int stopTask(String path, Map<String, String> env) { log.info("run shutdown for compose execution of file", path); String stopTask = CommandBuilder.stopTask(path); return ProcessUtils.executeCommand(stopTask, null, env); }
private int rmTask(String path, Map<String, String> env) { log.info("run rm for compose execution of file", path); String stopTask = CommandBuilder.downTask(path); return ProcessUtils.executeCommand(stopTask, null, env); }
public List<String> getContainerIds() { String list = CommandBuilder.getContainerIds(fileName); try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { int exitCode = ProcessUtils.executeCommand(list, null, outputStream, null, null, buildDockerEnv()); if (exitCode == 0 && outputStream.toString() != null) { String commandOutput = outputStream.toString(); return parseListCommandOutput(commandOutput); } } catch (Exception e) { log.error("", e); } return Collections.emptyList(); }
private void updateImages(String path, ComposeMonitor monitor) { String pullCommand = CommandBuilder.pullImages(path); int imageUpdateExitCode = ProcessUtils.executeCommand(pullCommand, null, monitor.buildDockerEnv()); if (imageUpdateExitCode != 0) { log.error("unable to update images"); } }
private ComposeResult startCompose(final ComposeMonitor monitor, String path, final String appName, final DockerService dockerService) { int exitCode = ProcessUtils.executeCommand(CommandBuilder.launchTask(path), null, monitor.buildDockerEnv()); monitor.stopMonitoring(); if (exitCode == 0) { List<String> containerIds = monitor.getContainerIds(); List<ContainerDetails> res = containerIds.stream().map(dockerService::getContainer).collect(toList()); log.info("compose file: {} successfully executed, result: {}", path, res); ComposeResult.ComposeResultBuilder result = ComposeResult.builder().appName(appName).containerDetails(res); if (CollectionUtils.isEmpty(res)) { return result.resultCode(ResultCode.NOT_MODIFIED).build(); } return result.resultCode(ResultCode.OK).build(); } else { shutDown(monitor, path, dockerService); return ComposeResult.builder().resultCode(ResultCode.ERROR).appName(appName).build(); } }