diff --git a/bin/generate b/bin/generate index 483f58b..cd61056 100755 --- a/bin/generate +++ b/bin/generate @@ -9,12 +9,16 @@ curl ftp://yyy:QeY\!68\)4nH1@132.121.122.15:2222/service-cli-runner-1.0.0-SNAPSH ${jdk_path} -jar ${jars_path}/service-cli-runner.jar \ --spring.profiles.active=b12 \ --deploy.generate.command=true \ + --deploy.generate.command-pro=true \ --deploy.generate.uploader=true \ --deploy.generate.update-jar=true \ $arguments +chmod +x check/*.sh chmod +x cloud/*.sh chmod +x command/cli* chmod +x command/*.sh +chmod +x command-pro/cli* +chmod +x command-pro/*.sh chmod +x uploader/*.sh chmod +x *.sh diff --git a/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/DeployInformationProperties.java b/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/DeployInformationProperties.java index 08a1bc8..e4be471 100644 --- a/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/DeployInformationProperties.java +++ b/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/DeployInformationProperties.java @@ -75,12 +75,21 @@ public class DeployInformationProperties { } public static final class Generate { + private Boolean check = true; private Boolean cloud = true; private Boolean command = true; private Boolean commandPro = true; private Boolean uploader = true; private Boolean updateJar = true; + public Boolean getCheck() { + return check; + } + + public void setCheck(Boolean check) { + this.check = check; + } + public Boolean getCloud() { return cloud; } @@ -124,7 +133,8 @@ public class DeployInformationProperties { @Override public String toString() { return "Generate{" + - "cloud=" + cloud + + "check=" + check + + ", cloud=" + cloud + ", command=" + command + ", commandPro=" + commandPro + ", uploader=" + uploader + diff --git a/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/RunnerApplication.java b/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/RunnerApplication.java index 9133888..428d491 100644 --- a/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/RunnerApplication.java +++ b/service-cli/service-cli-runner/src/main/java/com/lanyuanxiaoyao/service/cli/runner/RunnerApplication.java @@ -92,6 +92,8 @@ public class RunnerApplication implements ApplicationRunner { public void run(ApplicationArguments args) throws IOException { logger.info("Loading runtime info: {}", mapper.writeValueAsString(runtimeInfo)); + if (deployInformationProperties.getGenerate().getCheck()) + generateCheck(Paths.get("check")); if (deployInformationProperties.getGenerate().getCloud()) generateCloud(Paths.get("cloud")); if (deployInformationProperties.getGenerate().getCommand()) @@ -104,6 +106,22 @@ public class RunnerApplication implements ApplicationRunner { generateUpdateJar(Paths.get("")); } + private void generateCheck(Path root) throws IOException { + Files.createDirectories(root); + String absolutRootPath = root.toAbsolutePath().toString(); + logger.info("Current path: {}", absolutRootPath); + + TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); + Template syncTemplate = engine.getTemplate("check/check.ftl"); + String syncScript = syncTemplate.render(MapUtil.builder() + .put("currentPath", absolutRootPath) + .put("runtime", runtimeInfo) + .build()); + Path checkScriptFile = Paths.get(root.toString(), "check.sh"); + Files.deleteIfExists(checkScriptFile); + Files.write(checkScriptFile, syncScript.getBytes()); + } + private void generateCloud(Path root) throws IOException { Files.createDirectories(root); String absolutRootPath = root.toAbsolutePath().toString(); @@ -115,12 +133,6 @@ public class RunnerApplication implements ApplicationRunner { deployPlans = mapper.readValue(new String(Files.readAllBytes(planPath)), new TypeReference>>() {}); } - ImmutableList clusters = Lists.mutable.of(runtimeInfo.getYarn().getSyncClusters().split(",")) - .withAll(Lists.mutable.of(runtimeInfo.getYarn().getCompactionClusters().split(","))) - .collect(n -> runtimeInfo.getYarn().getStoreCluster() + n) - .distinct() - .toImmutable(); - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); Template deployTemplate = engine.getTemplate("cloud/deploy.ftl"); for (ServiceInfoWrapper serviceInfo : serviceInfoList) { diff --git a/service-cli/service-cli-runner/src/main/resources/template/check/check.ftl b/service-cli/service-cli-runner/src/main/resources/template/check/check.ftl new file mode 100644 index 0000000..c36e935 --- /dev/null +++ b/service-cli/service-cli-runner/src/main/resources/template/check/check.ftl @@ -0,0 +1,4 @@ +#!/bin/bash +mkdir -p ${runtime.jarPath} +curl ${runtime.downloadUrl}/service-check-1.0.0-SNAPSHOT.jar -o ${runtime.jarPath}/service-check.jar +${runtime.jdkPath}/bin/java -jar ${runtime.jarPath}/service-check.jar