Commit 92e69484 authored by 赵啸非's avatar 赵啸非

添加前端解压

parent 2b148fc2
......@@ -97,24 +97,20 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
//读取本工程的资源文件 检测压缩包类型
//String sourcePath = "/project/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getDesc() + "/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue() + ".tar.gz";
//InputStream inputStream = this.getClass().getResourceAsStream(sourcePath);
String sourcePath = this.publishPath+"/temp/project/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getDesc() + "/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue() + ".tar.gz";
String sourcePath = this.publishPath + "/temp/project/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getDesc() + "/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue() + ".tar.gz";
File file = new File(sourcePath);
log.info("文件存在:{}", file.exists());
File destDir = new File(setupProjectEntity.getProjectPath());
if(! file.exists()){
if (!file.exists()) {
throw new AppException("请上传项目工程文件!");
}
final TarGZipUnArchiver ua = new TarGZipUnArchiver();
// Logging - as @Akom noted, logging is mandatory in newer versions, so you can use a code like this to configure it:
ConsoleLoggerManager manager = new ConsoleLoggerManager();
manager.initialize();
ua.enableLogging(manager.getLoggerForComponent("bla"));
// -- end of logging part
ua.setSourceFile(file);
destDir.mkdirs();
ua.setDestDirectory(destDir);
......@@ -125,9 +121,7 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
String str = RuntimeUtil.execForStr(shell);
log.info("解压命令结果:{}", str);*/
// InputStream inputStream = FileUtil.getInputStream(file);
// InputStream inputStream = FileUtil.getInputStream(file);
///Hutoo.unGzip(inputStream, setupProjectEntity.getProjectPath());
......@@ -162,9 +156,7 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
if (SystemUtil.getOsInfo().isLinux()) {
//todo 执行部署脚本
//后端服务,创建service 启动服务
//RuntimeUtil.exec()
//callScript("project_deploy.sh","4",publicPath+"/bin/");
callScript("project_deploy.sh", "4", publicPath + "/bin/");
} else if (SystemUtil.getOsInfo().isWindows()) {
//todo
}
......@@ -173,7 +165,36 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
} else if (ProjectTypeEnum.前端.getValue() == setupProjectEntity.getProjectType()) {
//TODO: 前端逻辑
//TODO: 前端逻辑 静态文件,只需要解压到指定目录即可
String path = this.publishPath + "/temp/project/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getDesc() + "/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue();
String sourceUiPath = path + ".tar.gz";
File uiFile = new File(sourceUiPath);
//查看zip文件是否存在
String sourceUiZipPath = path + ".zip";
File uiZipFile = new File(sourceUiZipPath);
File destDir = new File(setupProjectEntity.getProjectPath());
log.info("tar文件存在:{},zip文件存在:{}", uiFile.exists(), uiZipFile.exists());
if (uiFile.exists()) {
//解压tar.gz
final TarGZipUnArchiver ua = new TarGZipUnArchiver();
ConsoleLoggerManager manager = new ConsoleLoggerManager();
manager.initialize();
ua.enableLogging(manager.getLoggerForComponent("bla"));
ua.setSourceFile(uiFile);
destDir.mkdirs();
ua.setDestDirectory(destDir);
ua.extract();
} else if (uiZipFile.exists()) {
ZipUtil.unzip(uiZipFile, destDir);
} else {
throw new AppException("请上传项目工程资源文件!");
}
} else if (ProjectTypeEnum.资源.getValue() == setupProjectEntity.getProjectType()) {
//TODO: 资源逻辑
}
......@@ -298,8 +319,8 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
log.info(workspace[0]);
}
String[] evnp = {"val=2", "call=Bash Shell"};
// Process process = Runtime.getRuntime().exec("su");
Process process = Runtime.getRuntime().exec(cmd, evnp, dir);
// Process process = Runtime.getRuntime().exec("su");
Process process = Runtime.getRuntime().exec(cmd, evnp, dir);
// process = Runtime.getRuntime().exec(cmd);
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
......@@ -347,7 +368,6 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
File file = FileUtil.file("F:/test.tar.gz");
InputStream inputStream = FileUtil.getInputStream(file);
///Hutoo.unGzip(inputStream, setupProjectEntity.getProjectPath());
......@@ -357,8 +377,7 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
ZipUtils.unGzip(inputStream, "F:/");
// CompressorInputStream gz = CompressUtil.getIn("gz", FileUtil.getInputStream(file));
// CompressorInputStream gz = CompressUtil.getIn("gz", FileUtil.getInputStream(file));
/* Extractor extractor = CompressUtil.createExtractor(
CharsetUtil.defaultCharset(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment