private Launcher(String[] args) throws JSAPException { JSAP jsap = this.defineArgs(); JSAPResult arguments = jsap.parse(args); LauncherUtils.checkArguments(jsap, arguments, LauncherType.CHECKBRANCHES); this.initConfig(arguments); this.initNotifiers(); }
private void runPool() throws IOException { String runId = this.config.getRunId(); List<String> branchNames = this.readListOfBranches(); LOGGER.info("Find "+branchNames.size()+" branches to run."); this.docker = DockerHelper.initDockerClient(); String imageId = DockerHelper.findDockerImage(this.config.getDockerImageName(), this.docker); LOGGER.info("Found the following docker image id: "+imageId); ExecutorService executorService = Executors.newFixedThreadPool(this.config.getNbThreads()); for (String branchName : branchNames) { RunnablePipelineContainer runnablePipelineContainer = new RunnablePipelineContainer(imageId, branchName); submittedRunnablePipelineContainers.add(runnablePipelineContainer); executorService.submit(runnablePipelineContainer); } executorService.shutdown(); try { if (executorService.awaitTermination(this.config.getGlobalTimeout(), TimeUnit.DAYS)) { LOGGER.info("Job finished within time."); } else { LOGGER.warn("Timeout launched: the job is running for one day. Force stopped "+ submittedRunnablePipelineContainers.size()+" docker container(s)."); executorService.shutdownNow(); } } catch (InterruptedException e) { LOGGER.error("Error while await termination. Force stopped "+ submittedRunnablePipelineContainers.size()+" docker container(s).", e); executorService.shutdownNow(); } this.docker.close(); if (this.endProcessNotifier != null) { this.endProcessNotifier.notifyEnd(); } }
} catch (InterruptedException e) { LOGGER.error("Error while running the container for branch name "+branchName, e); killDockerContainer(docker, containerId); } catch (DockerException e) { LOGGER.error("Error while creating or running the container for branch name "+branchName, e);