mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
[fix] fix the container template generator bug
This commit is contained in:
parent
a2725d21cc
commit
babd5c362f
@ -5,11 +5,9 @@ import net.lingala.zip4j.ZipFile;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* oms-worker container 生成器
|
||||
@ -33,14 +31,17 @@ public class ContainerTemplateGenerator {
|
||||
*/
|
||||
public static File generate(String group, String artifact, String name, String packageName, Integer javaVersion) throws IOException {
|
||||
|
||||
URL resource = ContainerTemplateGenerator.class.getClassLoader().getResource(ORIGIN_FILE_NAME + ".zip");
|
||||
if (resource == null) {
|
||||
throw new RuntimeException("generate container template failed, can't find zip file in classpath.");
|
||||
String workerDir = OmsFileUtils.genTemporaryPath();
|
||||
File originJar = new File(workerDir + "tmp.jar");
|
||||
String tmpPath = workerDir + "/unzip/";
|
||||
|
||||
// CentOS 7 上 getResource 会报 FileNotFoundException,原因不详...
|
||||
try (InputStream is = ContainerTemplateGenerator.class.getClassLoader().getResourceAsStream(ORIGIN_FILE_NAME + ".zip")) {
|
||||
Objects.requireNonNull(is, "generate container template failed, can't find zip file in classpath.");
|
||||
FileUtils.copyInputStreamToFile(is, originJar);
|
||||
}
|
||||
|
||||
ZipFile zipFile = new ZipFile(resource.getFile());
|
||||
|
||||
String tmpPath = OmsFileUtils.genTemporaryPath();
|
||||
ZipFile zipFile = new ZipFile(originJar);
|
||||
zipFile.extractAll(tmpPath);
|
||||
String rootPath = tmpPath + ORIGIN_FILE_NAME;
|
||||
|
||||
@ -103,6 +104,9 @@ public class ContainerTemplateGenerator {
|
||||
ZipFile finZip = new ZipFile(finPath);
|
||||
finZip.addFolder(new File(rootPath));
|
||||
|
||||
// 6. 删除源文件
|
||||
FileUtils.forceDelete(originJar);
|
||||
|
||||
return finZip.getFile();
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,6 @@ echo "================== 拷贝 jar =================="
|
||||
/bin/cp -rf oh-my-scheduler-server/target/*.jar others/oms-server.jar
|
||||
ls -l others/oms-server.jar
|
||||
echo "================== debug 模式启动 =================="
|
||||
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar others/oms-server.jar
|
||||
nohup java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar others/oms-server.jar > oms-server.log &
|
||||
sleep 100
|
||||
tail --pid=$$ -f -n 1000 others/oms-server.log
|
||||
|
Loading…
x
Reference in New Issue
Block a user