Commit a39d92e1 authored by 赵啸非's avatar 赵啸非

添加批量激活设备

parent f9df4ac1
......@@ -81,6 +81,7 @@ start_service() {
#部署后台服务
project_deploy() {
writelog "${PROJECT_NAME}_deploy"
systemctl stop ${PROJECT_NAME}
clear_deploy ${PROJECT_SERVICE} ${PROJECT_EXECPATH}
writelog "${PROJECT_NAME}_clear_finish"
tar -zvxf ./${PROJECT_FILENAME} -C ${PUBLISH_PATH}
......
......@@ -9,7 +9,6 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.AppTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.utils.SynchronousLocalShellCommand;
import com.mortals.xhx.module.app.dao.AppPublishDao;
import com.mortals.xhx.module.app.model.AppPublishEntity;
import com.mortals.xhx.module.app.service.AppPublishService;
......@@ -20,9 +19,7 @@ import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
......@@ -132,27 +129,20 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
}
String disPath = "/home/temp/";
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
String scriptPath = "/home/temp/" + appPublishEntity.getAppCode() + "/deploy.sh";
// RuntimeUtil.exec("chmod 755 "+scriptPath);
// this.runSyncCommand(scriptPath);
// ProcessBuilder sh = new ProcessBuilder("sh", scriptPath);
ProcessBuilder sh = new ProcessBuilder("sh",scriptPath);
File file = new File("/home/temp/" + appPublishEntity.getAppCode() + "/deploy.sh");
asynExeLocalComand(file, sh);
//执行sh发布脚本
// RuntimeUtil.exec("/bin/sh /home/temp/"+appPublishEntity.getAppCode()+"/deploy.sh");
}
asynExeLocalComand(null, sh);
}
this.update(appPublishEntity, context);
}
public void asynExeLocalComand(File file, ProcessBuilder pb) throws IOException {
// 不使用Runtime.getRuntime().exec(command)的方式,因为无法设置以下特性
// Java执行本地命令是启用一个子进程处理,默认情况下子进程与父进程I/O通过管道相连(默认ProcessBuilder.Redirect.PIPE)
......@@ -174,18 +164,4 @@ public class AppPublishServiceImpl extends AbstractCRUDServiceImpl<AppPublishDao
pb.start();
}
/**
* 执行同步的命令操作
*
* @param commandStr
*/
private void runSyncCommand(String commandStr) {
log.info("开始执行:" + commandStr);
List<String> commandList = Arrays.asList("bash", "-c", commandStr);
SynchronousLocalShellCommand command = new SynchronousLocalShellCommand(commandList);
String commandRsp = command.doCommand();
log.info("同步执行结果:" + commandRsp);
}
}
\ No newline at end of file
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