feat(uploader): 增加文件上传下载模块
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 uploader = true;
|
||||
|
||||
public Boolean getCloud() {
|
||||
return cloud;
|
||||
@@ -94,11 +95,20 @@ public class DeployInformationProperties {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public Boolean getUploader() {
|
||||
return uploader;
|
||||
}
|
||||
|
||||
public void setUploader(Boolean uploader) {
|
||||
this.uploader = uploader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Generate{" +
|
||||
"cloud=" + cloud +
|
||||
", command=" + command +
|
||||
", uploader=" + uploader +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
generateCloud(Paths.get("cloud"));
|
||||
if (deployInformationProperties.getGenerate().getCommand())
|
||||
generateCommand(Paths.get("command"));
|
||||
if (deployInformationProperties.getGenerate().getUploader()) {
|
||||
generateUploader(Paths.get("uploader"));
|
||||
}
|
||||
}
|
||||
|
||||
private void generateCloud(Path root) throws IOException {
|
||||
@@ -269,4 +272,34 @@ public class RunnerApplication implements ApplicationRunner {
|
||||
Files.deleteIfExists(updateScriptFile);
|
||||
Files.write(updateScriptFile, updateScript.getBytes());
|
||||
}
|
||||
|
||||
private void generateUploader(Path root) throws IOException {
|
||||
String absolutRootPath = root.toAbsolutePath().toString();
|
||||
logger.info("Current path: {}", absolutRootPath);
|
||||
|
||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH));
|
||||
Template startTemplate = engine.getTemplate("uploader/start.ftl");
|
||||
String startScript = startTemplate.render(MapUtil.builder()
|
||||
.put("currentPath", absolutRootPath)
|
||||
.put("runtime", runtimeInfo)
|
||||
.build());
|
||||
Path startScriptFile = Paths.get(root.toString(), "start.sh");
|
||||
Files.deleteIfExists(startScriptFile);
|
||||
Files.write(startScriptFile, startScript.getBytes());
|
||||
|
||||
Template updateTemplate = engine.getTemplate("uploader/update.ftl");
|
||||
String updateScript = updateTemplate.render(MapUtil.builder()
|
||||
.put("currentPath", absolutRootPath)
|
||||
.put("runtime", runtimeInfo)
|
||||
.build());
|
||||
Path updateScriptFile = Paths.get(root.toString(), "update.sh");
|
||||
Files.deleteIfExists(updateScriptFile);
|
||||
Files.write(updateScriptFile, updateScript.getBytes());
|
||||
|
||||
ClassPathResource stopFile = new ClassPathResource("script/stop.sh");
|
||||
String stopScript = new String(IoUtil.readBytes(stopFile.getInputStream()));
|
||||
// 一个魔法操作
|
||||
stopScript = stopScript.replaceAll("\\$1", "service-uploader.jar");
|
||||
Files.write(Paths.get(root.toString(), "stop.sh"), stopScript.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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} <#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} -Duploader.backend=local -Duploader.tmp-dir=${runtime.dataPath}/uploader -jar ${runtime.jarPath}/service-uploader.jar
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
curl ftp://yyy:QeY\!68\)4nH1@132.121.122.15:2222/service-uploader-1.0.0-SNAPSHOT.jar -o ${runtime.jarPath}/service-uploader.jar
|
||||
Reference in New Issue
Block a user