feat(command-pro): 增加一个命令行工具用于直接操作hadoop等组件
基于微服务的命令行适合日常产品化运维操作,但能够直接操作Hadoop等组件,便于开发测试使用,因此增加一个模块用于开发过程中测试使用
This commit is contained in:
@@ -77,6 +77,7 @@ public class DeployInformationProperties {
|
||||
public static final class Generate {
|
||||
private Boolean cloud = true;
|
||||
private Boolean command = true;
|
||||
private Boolean commandPro = true;
|
||||
private Boolean uploader = true;
|
||||
private Boolean updateJar = true;
|
||||
|
||||
@@ -96,6 +97,14 @@ public class DeployInformationProperties {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public Boolean getCommandPro() {
|
||||
return commandPro;
|
||||
}
|
||||
|
||||
public void setCommandPro(Boolean commandPro) {
|
||||
this.commandPro = commandPro;
|
||||
}
|
||||
|
||||
public Boolean getUploader() {
|
||||
return uploader;
|
||||
}
|
||||
@@ -117,6 +126,7 @@ public class DeployInformationProperties {
|
||||
return "Generate{" +
|
||||
"cloud=" + cloud +
|
||||
", command=" + command +
|
||||
", commandPro=" + commandPro +
|
||||
", uploader=" + uploader +
|
||||
", updateJar=" + updateJar +
|
||||
'}';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.cli.runner;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
@@ -34,7 +33,6 @@ import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
@@ -98,6 +96,8 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
generateCloud(Paths.get("cloud"));
|
||||
if (deployInformationProperties.getGenerate().getCommand())
|
||||
generateCommand(Paths.get("command"));
|
||||
if (deployInformationProperties.getGenerate().getCommandPro())
|
||||
generateCommand(Paths.get("command-pro"));
|
||||
if (deployInformationProperties.getGenerate().getUploader())
|
||||
generateUploader(Paths.get("uploader"));
|
||||
if (deployInformationProperties.getGenerate().getUpdateJar())
|
||||
@@ -252,7 +252,7 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
logger.info("Current path: {}", absolutRootPath);
|
||||
|
||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
Template commandTemplate = engine.getTemplate("command/cli.ftl");
|
||||
Template commandTemplate = engine.getTemplate(root.toFile().getName() + "/cli.ftl");
|
||||
String commandScript = commandTemplate.render(MapUtil.builder()
|
||||
.put("currentPath", absolutRootPath)
|
||||
.put("runtime", runtimeInfo)
|
||||
@@ -262,7 +262,7 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
Files.deleteIfExists(commandScriptFile);
|
||||
Files.write(commandScriptFile, commandScript.getBytes());
|
||||
|
||||
Template commandDirectlyTemplate = engine.getTemplate("command/cli.ftl");
|
||||
Template commandDirectlyTemplate = engine.getTemplate(root.toFile().getName() + "/cli.ftl");
|
||||
String commandDirectlyScript = commandDirectlyTemplate.render(MapUtil.builder()
|
||||
.put("currentPath", absolutRootPath)
|
||||
.put("runtime", runtimeInfo)
|
||||
@@ -272,7 +272,7 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
Files.deleteIfExists(commandDirectlyScriptFile);
|
||||
Files.write(commandDirectlyScriptFile, commandDirectlyScript.getBytes());
|
||||
|
||||
Template updateTemplate = engine.getTemplate("command/update.ftl");
|
||||
Template updateTemplate = engine.getTemplate(root.toFile().getName() + "/update.ftl");
|
||||
String updateScript = updateTemplate.render(MapUtil.builder()
|
||||
.put("currentPath", absolutRootPath)
|
||||
.put("runtime", runtimeInfo)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
mkdir -p ${runtime.jarPath}
|
||||
export JASYPT_ENCRYPTOR_PASSWORD='r#(R,P\"Dp^A47>WSn:Wn].gs/+\"v:q_Q*An~zF*g-@j@jtSTv5H/,S-3:R?r9R}.'
|
||||
${runtime.jdkPath}/bin/java <#noparse>-Ddeploy.datetime=$(date +%Y%m%d%H%M%S) -Ddeploy.hostname=$(hostname) -Ddeploy.hostname-full=$(hostname -f) -Ddeploy.start-time=$(date +%Y%m%d%H%M%S)</#noparse> -Dlogging.parent=${runtime.logPath} -Dloki.url=${runtime.loki.servicePushUrl} -Dspring.cloud.zookeeper.connect-string=${runtime.zkUrl} -Dyarn-cluster.sync-clusters=${runtime.yarn.syncClusters} -Dyarn-cluster.compaction-clusters=${runtime.yarn.compactionClusters} -jar ${runtime.jarPath}/service-command-pro.jar<#if directly> $@</#if>
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
curl ${runtime.downloadUrl}/service-command-pro-1.0.0-SNAPSHOT.jar -o ${runtime.jarPath}/service-command-pro.jar
|
||||
Reference in New Issue
Block a user