feat(cli): 增加check模块的脚本生生成

This commit is contained in:
v-zhangjc9
2024-05-16 12:22:16 +08:00
parent 9915da5018
commit 20e3fdae87
4 changed files with 37 additions and 7 deletions

View File

@@ -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 +

View File

@@ -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<Map<String, List<String>>>() {});
}
ImmutableList<String> 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) {

View File

@@ -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