Parcourir la source

优化 BuildDeployService 接口

reghao il y a 4 ans
Parent
commit
f38ee2fd44
28 fichiers modifiés avec 304 ajouts et 201 suppressions
  1. 19 0
      common/src/main/java/cn/reghao/autodop/common/util/NotAvailable.java
  2. 2 1
      dagent/src/main/java/cn/reghao/autodop/dagent/app/DockerAppServiceImpl.java
  3. 6 21
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/BuildDeployController.java
  4. 28 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/constant/BuildStatus.java
  5. 28 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/constant/DeployStatus.java
  6. 29 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/AppBuilding.java
  7. 21 6
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/AppDeploying.java
  8. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/config/build/PackerConfig.java
  9. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/log/DeployLog.java
  10. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/AppBuildingVO.java
  11. 5 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/AppRunningVo.java
  12. 1 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppBuilder.java
  13. 7 20
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppDeployer.java
  14. 6 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java
  15. 5 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingService.java
  16. 35 7
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingServiceImpl.java
  17. 5 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingService.java
  18. 28 15
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingServiceImpl.java
  19. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java
  20. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployConfigServiceImpl.java
  21. 58 96
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployServiceImpl.java
  22. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/util/buildtool/packer/ZipPack.java
  23. 4 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/model/dto/AppMonitorDto.java
  24. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/impl/rpcresult/AppRpcClazzResultImpl.java
  25. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/HttpRequestUtil.java
  26. 4 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/interceptor/AppConfigInterceptor.java
  27. 1 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/util/db/PageSort.java
  28. 3 3
      dmaster/src/main/resources/templates/app/bd/index.html

+ 19 - 0
common/src/main/java/cn/reghao/autodop/common/util/NotAvailable.java

@@ -0,0 +1,19 @@
+package cn.reghao.autodop.common.util;
+
+/**
+ * @author reghao
+ * @date 2021-11-08 16:53:59
+ */
+public enum NotAvailable {
+    na("N/A");
+
+    private String desc;
+
+    NotAvailable(String desc) {
+        this.desc = desc;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 2 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/app/DockerAppServiceImpl.java

@@ -10,6 +10,7 @@ import cn.reghao.autodop.common.docker.DockerException;
 import cn.reghao.autodop.common.docker.po.Config;
 import cn.reghao.autodop.common.docker.po.HostConfig;
 import cn.reghao.autodop.common.util.ExceptionUtil;
+import cn.reghao.autodop.common.util.NotAvailable;
 import cn.reghao.jdkutil.converter.DateTimeConverter;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import com.github.dockerjava.api.command.InspectContainerResponse;
@@ -56,7 +57,7 @@ public class DockerAppServiceImpl implements AppService {
         if (image != null) {
             appStatus.setCommitId(image.split(":")[1]);
         } else {
-            appStatus.setCommitId("N/A");
+            appStatus.setCommitId(NotAvailable.na.getDesc());
         }
 
         InspectContainerResponse.ContainerState state = containerInfo.getState();

+ 6 - 21
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/BuildDeployController.java

@@ -1,8 +1,6 @@
 package cn.reghao.autodop.dmaster.app.controller;
 
-import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
 import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
-import cn.reghao.autodop.dmaster.util.UploadDownload;
 import cn.reghao.jdkutil.result.WebBody;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import com.google.gson.JsonObject;
@@ -12,14 +10,9 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
 
 /**
  * @author reghao
@@ -31,27 +24,25 @@ import java.io.IOException;
 @RequestMapping("/api/app/bd")
 public class BuildDeployController {
     private final BuildDeployService buildDeployService;
-    private final UploadDownload uploadDownload;
 
-    public BuildDeployController(BuildDeployService buildDeployService, UploadDownload uploadDownload) {
+    public BuildDeployController(BuildDeployService buildDeployService) {
         this.buildDeployService = buildDeployService;
-        this.uploadDownload = uploadDownload;
     }
 
     @ApiOperation(value = "构建部署应用")
     @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
     public String buildAndDeploy(@RequestParam("appId") String appId) throws Exception {
-        String ret = buildDeployService.buildAndDeploy(appId);
-        return WebBody.successWithMsg(ret);
+        buildDeployService.buildAndDeploy(appId);
+        return WebBody.success();
     }
 
     @ApiOperation(value = "构建应用")
     @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
     @PostMapping(value = "/build", produces = MediaType.APPLICATION_JSON_VALUE)
     public String build(@RequestParam("appId") String appId) throws Exception {
-        String ret = buildDeployService.build(appId);
-        return WebBody.successWithMsg(ret);
+        buildDeployService.build(appId);
+        return WebBody.success();
     }
 
     @ApiOperation(value = "部署应用")
@@ -89,14 +80,8 @@ public class BuildDeployController {
 
     @ApiOperation(value = "构建包下载接口")
     @GetMapping("/dl/{buildLogId}")
-    public ResponseEntity dlPackage(@PathVariable("buildLogId") String buildLogId, HttpServletResponse response)
-            throws IOException {
+    public void dlPackage(@PathVariable("buildLogId") String buildLogId, HttpServletResponse response) throws Exception {
         buildDeployService.downloadPackage(buildLogId);
-        String filePath = LocalBuildDir.packDir + File.separator + "filename";
-        FileInputStream fileInputStream = new FileInputStream(filePath);
-        BufferedInputStream bis = new BufferedInputStream(fileInputStream);
-        uploadDownload.download("filename", bis, response);
-        return null;
     }
 
     @ApiOperation(value = "当前正在构建的应用")

+ 28 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/constant/BuildStatus.java

@@ -0,0 +1,28 @@
+package cn.reghao.autodop.dmaster.app.model.constant;
+
+/**
+ * 构建状态
+ *
+ * @author reghao
+ * @date 2021-11-08 16:35:42
+ */
+public enum BuildStatus {
+    neverBuild(-1, "从未构建"), onBuilding(0, "构建中"),
+    buildSuccess(1, "构建成功"), buildFail(2, "构建失败");
+
+    private final Integer code;
+    private final String desc;
+
+    BuildStatus(Integer code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 28 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/constant/DeployStatus.java

@@ -0,0 +1,28 @@
+package cn.reghao.autodop.dmaster.app.model.constant;
+
+/**
+ * 部署状态
+ *
+ * @author reghao
+ * @date 2021-11-08 16:35:42
+ */
+public enum DeployStatus {
+    neverDeploy(0, "从未部署"), onDeploying(0, "部署中"),
+    deploySuccess(1, "部署成功"), deployFail(2, "部署失败");
+
+    private final Integer code;
+    private final String desc;
+
+    DeployStatus(Integer code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 29 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/AppBuilding.java

@@ -1,5 +1,7 @@
 package cn.reghao.autodop.dmaster.app.model.po;
 
+import cn.reghao.autodop.dmaster.app.model.constant.BuildStatus;
+import cn.reghao.autodop.common.util.NotAvailable;
 import cn.reghao.jdkutil.result.ResultStatus;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
@@ -11,6 +13,7 @@ import lombok.*;
 import javax.persistence.Entity;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
+import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
 
 /**
@@ -27,19 +30,42 @@ public class AppBuilding extends BaseEntity<Integer> {
     @JoinColumn(nullable = false, unique = true)
     @OneToOne
     private AppConfig appConfig;
+    @NotNull
     private String buildLogId;
+    @NotNull
     private String commitId;
+    @NotNull
     private LocalDateTime commitTime;
+    @NotNull
     private String buildResult;
+    @NotNull
     private LocalDateTime buildTime;
+    @NotNull
     private String packagePath;
+    @NotNull
     private String buildBy;
 
     public AppBuilding(AppConfig appConfig) {
         this.appConfig = appConfig;
+        this.commitId = NotAvailable.na.getDesc();
+        this.commitTime = LocalDateTime.MIN;
+        this.buildResult = BuildStatus.neverBuild.getDesc();
+        this.buildTime = LocalDateTime.MIN;
+        this.packagePath = NotAvailable.na.getDesc();
+        this.buildBy = NotAvailable.na.getDesc();
     }
 
-    public void update(BuildLog buildLog) {
+    public void beforeBuild(String buildBy) {
+        this.setCommitId(NotAvailable.na.getDesc());
+        this.setCommitTime(DateTimeConverter.localDateTime(0));
+        this.setBuildResult(BuildStatus.onBuilding.getDesc());
+        this.setBuildTime(LocalDateTime.MIN);
+        this.setPackagePath(NotAvailable.na.getDesc());
+        this.setBuildBy(buildBy);
+        this.setUpdateTime(LocalDateTime.now());
+    }
+
+    public void afterBuild(BuildLog buildLog) {
         this.setBuildLogId(buildLog.getId());
         CommitInfo commitInfo = buildLog.getCommitInfo();
         if (commitInfo != null) {
@@ -49,9 +75,9 @@ public class AppBuilding extends BaseEntity<Integer> {
 
         int code = buildLog.getResult().getCode();
         if (code == ResultStatus.SUCCESS.getCode()) {
-            this.setBuildResult(ResultStatus.SUCCESS.getMsg());
+            this.setBuildResult(BuildStatus.buildSuccess.getDesc());
         } else {
-            this.setBuildResult(ResultStatus.FAIL.getMsg());
+            this.setBuildResult(BuildStatus.buildFail.getDesc());
         }
         this.setBuildTime(buildLog.getBuildTime().getBuildTime());
         this.setPackagePath(buildLog.getPackagePath());

+ 21 - 6
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/AppDeploying.java

@@ -1,7 +1,9 @@
 package cn.reghao.autodop.dmaster.app.model.po;
 
+import cn.reghao.autodop.dmaster.app.model.constant.DeployStatus;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
+import cn.reghao.autodop.common.util.NotAvailable;
 import cn.reghao.autodop.dmaster.util.db.BaseEntity;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.ResultStatus;
@@ -10,6 +12,7 @@ import lombok.*;
 import javax.persistence.Entity;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
+import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
 
 /**
@@ -26,33 +29,45 @@ public class AppDeploying extends BaseEntity<Integer> {
     @JoinColumn(nullable = false, unique = true)
     @OneToOne
     private AppDeployConfig appDeployConfig;
+    @NotNull
     private String buildLogId;
+    @NotNull
     private String commitId;
+    @NotNull
     private String packagePath;
+    @NotNull
     private String deployBy;
+    @NotNull
     private LocalDateTime deployTime;
+    @NotNull
     private String deployResult;
 
     public AppDeploying(AppDeployConfig appDeployConfig) {
         this.appDeployConfig = appDeployConfig;
+        this.buildLogId = NotAvailable.na.getDesc();
+        this.commitId = NotAvailable.na.getDesc();
+        this.packagePath = NotAvailable.na.getDesc();
+        this.deployBy = NotAvailable.na.getDesc();
+        this.deployTime = LocalDateTime.MIN;
+        this.deployResult = DeployStatus.neverDeploy.getDesc();
     }
 
-    public void updateBefore(String buildLogId, String commitId, String packagePath, String deployBy) {
+    public void beforeDeploy(String buildLogId, String commitId, String packagePath, String deployBy) {
         this.buildLogId = buildLogId;
         this.commitId = commitId;
         this.packagePath = packagePath;
         this.deployBy = deployBy;
-        this.deployTime = null;
-        this.deployResult = "N/A";
+        this.deployTime = LocalDateTime.MIN;
+        this.deployResult = DeployStatus.onDeploying.getDesc();
     }
 
-    public void updateAfter(DeployLog deployLog) {
+    public void afterDeploy(DeployLog deployLog) {
         this.deployTime = deployLog.getDeployTime();
         Result result = deployLog.getResult();
         if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
-            this.deployResult = ResultStatus.SUCCESS.getMsg();
+            this.deployResult = DeployStatus.deploySuccess.getDesc();
         } else {
-            this.deployResult = deployLog.getResult().getMsg();
+            this.deployResult = DeployStatus.deployFail.getDesc();
         }
     }
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/config/build/PackerConfig.java

@@ -30,7 +30,7 @@ public class PackerConfig extends BaseEntity<Integer> {
     @Column(nullable = false, unique = true)
     @NotBlank(message = "打包工具名字不能为空白字符串")
     private String name;
-    // 构建生成的可执行文件及配置文件, 脚本文件等所在的目录名, 目录位于 appRootPath
+    // 构建生成的可执行文件及配置文件, 脚本文件等所在的目录名, 目录位于 appRootPath
     @NotNull
     private String binfilesDirname;
     // 打包后的应用存放的位置,可以是一个本地目录,也可以是一个网络位置

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/log/DeployLog.java

@@ -33,7 +33,7 @@ public class DeployLog extends BaseDocument {
         this.deployBy = deployBy;
     }
 
-    public void update(DeployResult deployResult) {
+    public void updateAfterDeploy(DeployResult deployResult) {
         this.deployTime = deployResult.getDeployTime();
         this.result = deployResult.getResult();
     }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/AppBuildingVO.java

@@ -33,7 +33,7 @@ public class AppBuildingVO {
         this.appType = appConfig.getAppType();
         this.env = appConfig.getEnv();
         this.repoBranch = appConfig.getRepoBranch();
-        this.httpPort = appConfig.getHttpPort();
+        this.httpPort = appConfig.getHttpPort() == null ? -1 : appConfig.getHttpPort();
 
         this.buildLogId = appBuilding.getBuildLogId();
         this.commitId = appBuilding.getCommitId();

+ 5 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/AppRunningVo.java

@@ -3,6 +3,7 @@ package cn.reghao.autodop.dmaster.app.model.vo;
 import cn.reghao.autodop.dmaster.app.model.po.AppRunning;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.machine.model.po.MachineHost;
+import cn.reghao.autodop.common.util.NotAvailable;
 import cn.reghao.jdkutil.converter.DateTimeConverter;
 import lombok.Data;
 
@@ -35,8 +36,10 @@ public class AppRunningVo {
         this.healthCheck = appConfig.getHealthCheck();
         this.packagePath = appRunning.getAppDeploying().getPackagePath();
         this.status = appRunning.getStatus();
-        this.startTime = appRunning.getStartTime() != null ? DateTimeConverter.format(appRunning.getStartTime()) : "N/A";
+        this.startTime = appRunning.getStartTime() != null ?
+                DateTimeConverter.format(appRunning.getStartTime()) : NotAvailable.na.getDesc();
         this.pid = appRunning.getPid() != null ? appRunning.getPid() : -1;
-        this.lastCheck = appRunning.getLastCheck() != null ? DateTimeConverter.format(appRunning.getLastCheck()) : "N/A";
+        this.lastCheck = appRunning.getLastCheck() != null ?
+                DateTimeConverter.format(appRunning.getLastCheck()) : NotAvailable.na.getDesc();
     }
 }

+ 1 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppBuilder.java

@@ -128,7 +128,7 @@ public class AppBuilder {
                 codePacker = new DockerPack(packerConfig, app.getDockerfile());
                 break;
             case zip:
-                codePacker = new ZipPack(packerConfig);
+                codePacker = new ZipPack(packerConfig, appPackDir);
                 break;
             default:
         }
@@ -165,7 +165,6 @@ public class AppBuilder {
             }
         }
 
-        // TODO 拉取应用依赖的其他仓库(若存在)
         return new UpdateStatus(current, true);
     }
 
@@ -177,7 +176,6 @@ public class AppBuilder {
     public String pack() throws Exception {
         String appRootPath = compileDir() + File.separator + app.getAppRootPath();
         return codePacker.pack(app.getAppId(), latestCommitInfo.getCommitId(), appRootPath);
-        //return codePacker.pack(app.getAppId(), latestCommitInfo.getCommitId(), compileDir());
     }
 
     public String push(String localPath) throws DockerException {

+ 7 - 20
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppDeployer.java

@@ -6,13 +6,10 @@ import cn.reghao.autodop.common.msg.MsgQueue;
 import cn.reghao.autodop.common.msg.rpc.RpcMsg;
 import cn.reghao.autodop.common.msg.rpc.constant.AppRpcClazz;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployParam;
-import cn.reghao.autodop.dmaster.app.db.crud.AppDeployingCrud;
-import cn.reghao.autodop.dmaster.app.db.crud.log.DeployLogCrud;
-import cn.reghao.autodop.dmaster.app.db.query.AppDeployingQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.AppDeployConfigQuery;
-import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
+import cn.reghao.autodop.dmaster.app.service.bd.AppDeployingService;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import lombok.extern.slf4j.Slf4j;
@@ -31,23 +28,17 @@ import java.util.*;
 @Service
 public class AppDeployer {
     private final AsyncMqttClient mqttClient;
+    private final AppDeployingService deployingService;
     private final AppDeployConfigQuery deployConfigQuery;
-    private final AppDeployingQuery deployingQuery;
-    private final AppDeployingCrud deployingCrud;
-    private final DeployLogCrud logCrud;
 
-    public AppDeployer(AsyncMqttClient mqttClient, AppDeployConfigQuery deployConfigQuery,
-                       AppDeployingQuery deployingQuery, AppDeployingCrud deployingCrud,
-                       DeployLogCrud logCrud) {
+    public AppDeployer(AsyncMqttClient mqttClient, AppDeployingService deployingService,
+                       AppDeployConfigQuery deployConfigQuery) {
         this.mqttClient = mqttClient;
+        this.deployingService = deployingService;
         this.deployConfigQuery = deployConfigQuery;
-        this.deployingQuery = deployingQuery;
-        this.deployingCrud = deployingCrud;
-        this.logCrud = logCrud;
     }
 
     public void deploy(BuildLog buildLog) throws MqttException {
-        List<DeployLog> deployLogs = new ArrayList<>();
         String buildLogId = buildLog.getId();
         String appId = buildLog.getAppId();
         String packagePath = buildLog.getPackagePath();
@@ -79,13 +70,9 @@ public class AppDeployer {
             String topic = MsgQueue.dagentTopic(machineId);
             mqttClient.pubWithResult(topic, 1, message);
 
-            AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(deployConfig);
-            appDeploying.updateBefore(buildLogId, commitId, packagePath, deployBy);
-            deployingCrud.update(appDeploying);
-            deployLogs.add(new DeployLog(buildLogId, machineId, machineIpv4, deployBy));
+            deployingService.refreshBeforeDeploy(deployConfig, buildLog);
+            deployingService.addDeployLog(new DeployLog(buildLogId, machineId, machineIpv4, deployBy));
         }
-
-        logCrud.saveAll(deployLogs);
     }
 
     /**

+ 6 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java

@@ -7,10 +7,12 @@ import java.util.List;
  * @date 2021-09-17 11:30:16
  */
 public interface BuildDeployService {
-    String buildAndDeploy(String appId);
-    String build(String appId);
-    boolean deploy(String buildLogId);
-    void downloadPackage(String buildLogId);
+    void buildAndDeploy(String appId) throws Exception;
+    void build(String appId);
+    default void build(String appId, String commitId) {
+    }
+    void deploy(String buildLogId);
+    void downloadPackage(String buildLogId) throws Exception;
     List<String> currentlyBuilding();
     List<String> currentlyDeploying();
 }

+ 5 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingService.java

@@ -8,7 +8,10 @@ import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
  * @date 2021-10-22 14:48:26
  */
 public interface AppBuildingService {
-    void add(AppConfig appConfig);
-    void refresh(String appId, BuildLog buildLog);
+    void init(AppConfig appConfig);
     void delete(AppConfig appConfig);
+    void refreshBeforeBuild(String appId);
+    void refreshAfterBuild(BuildLog buildLog);
+    BuildLog addBuildLog(BuildLog buildLog);
+    void sendBuildNotify(BuildLog buildLog);
 }

+ 35 - 7
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingServiceImpl.java

@@ -1,11 +1,14 @@
 package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.dmaster.app.db.crud.AppBuildingCrud;
+import cn.reghao.autodop.dmaster.app.db.crud.log.BuildLogCrud;
 import cn.reghao.autodop.dmaster.app.db.query.AppBuildingQuery;
+import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
 import cn.reghao.autodop.dmaster.app.model.po.AppBuilding;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.service.bd.AppBuildingService;
+import cn.reghao.autodop.dmaster.rbac.UserContext;
 import org.springframework.stereotype.Service;
 
 /**
@@ -16,14 +19,19 @@ import org.springframework.stereotype.Service;
 public class AppBuildingServiceImpl implements AppBuildingService {
     private final AppBuildingQuery buildingQuery;
     private final AppBuildingCrud buildingCrud;
+    private final BuildLogQuery buildLogQuery;
+    private final BuildLogCrud buildLogCrud;
 
-    public AppBuildingServiceImpl(AppBuildingQuery buildingQuery, AppBuildingCrud buildingCrud) {
+    public AppBuildingServiceImpl(AppBuildingQuery buildingQuery, AppBuildingCrud buildingCrud,
+                                  BuildLogQuery buildLogQuery, BuildLogCrud buildLogCrud) {
         this.buildingQuery = buildingQuery;
         this.buildingCrud = buildingCrud;
+        this.buildLogQuery = buildLogQuery;
+        this.buildLogCrud = buildLogCrud;
     }
 
     @Override
-    public void add(AppConfig appConfig) {
+    public void init(AppConfig appConfig) {
         AppBuilding appBuilding = buildingQuery.findByAppConfig(appConfig);
         if (appBuilding == null) {
             appBuilding = new AppBuilding(appConfig);
@@ -32,19 +40,39 @@ public class AppBuildingServiceImpl implements AppBuildingService {
     }
 
     @Override
-    public void refresh(String appId, BuildLog buildLog) {
+    public void delete(AppConfig appConfig) {
+        AppBuilding appBuilding = buildingQuery.findByAppConfig(appConfig);
+        if (appBuilding != null) {
+            buildingCrud.delete(appBuilding);
+        }
+    }
+
+    @Override
+    public void refreshBeforeBuild(String appId) {
         AppBuilding appBuilding = buildingQuery.findByAppId(appId);
         if (appBuilding != null) {
-            appBuilding.update(buildLog);
+            String username = UserContext.currentUser().getNickname();
+            appBuilding.beforeBuild(username);
             buildingCrud.update(appBuilding);
         }
     }
 
     @Override
-    public void delete(AppConfig appConfig) {
-        AppBuilding appBuilding = buildingQuery.findByAppConfig(appConfig);
+    public void refreshAfterBuild(BuildLog buildLog) {
+        String appId = buildLog.getAppId();
+        AppBuilding appBuilding = buildingQuery.findByAppId(appId);
         if (appBuilding != null) {
-            buildingCrud.delete(appBuilding);
+            appBuilding.afterBuild(buildLog);
+            buildingCrud.update(appBuilding);
         }
     }
+
+    @Override
+    public BuildLog addBuildLog(BuildLog buildLog) {
+        return buildLogCrud.save(buildLog);
+    }
+
+    @Override
+    public void sendBuildNotify(BuildLog buildLog) {
+    }
 }

+ 5 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingService.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
+import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 
 /**
@@ -9,9 +10,11 @@ import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
  * @date 2021-10-22 14:45:22
  */
 public interface AppDeployingService {
-    void add(AppDeployConfig appDeployConfig);
-    void refresh(DeployLog deployLog);
+    void init(AppDeployConfig appDeployConfig);
     void delete(AppDeployConfig appDeployConfig);
+    void refreshBeforeDeploy(AppDeployConfig appDeployConfig, BuildLog buildLog);
+    void refreshAfterDeploy(DeployLog deployLog);
+    void addDeployLog(DeployLog deployLog);
     DeployLog updateDeployLog(DeployResult deployResult);
     void sendDeployNotify(DeployLog deployLog);
 }

+ 28 - 15
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingServiceImpl.java

@@ -10,7 +10,6 @@ import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
-import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
 import cn.reghao.autodop.dmaster.monitor.db.query.AppMonitorQuery;
 import cn.reghao.autodop.dmaster.monitor.model.po.AppMonitor;
 import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
@@ -32,28 +31,25 @@ public class AppDeployingServiceImpl implements AppDeployingService {
     private final BuildLogQuery buildLogQuery;
     private final DeployLogQuery deployLogQuery;
     private final DeployLogCrud deployLogCrud;
-    private final MachineHostQuery hostQuery;
     private final AppMonitorQuery appMonitorQuery;
     private final NotifyService notifyService;
 
     public AppDeployingServiceImpl(AppDeployingQuery deployingQuery, AppDeployingCrud deployingCrud,
                                    AppRunningService runningService, BuildLogQuery buildLogQuery,
                                    DeployLogQuery deployLogQuery, DeployLogCrud deployLogCrud,
-                                   MachineHostQuery hostQuery, AppMonitorQuery appMonitorQuery,
-                                   NotifyService notifyService) {
+                                   AppMonitorQuery appMonitorQuery, NotifyService notifyService) {
         this.deployingQuery = deployingQuery;
         this.deployingCrud = deployingCrud;
         this.runningService = runningService;
         this.buildLogQuery = buildLogQuery;
         this.deployLogQuery = deployLogQuery;
         this.deployLogCrud = deployLogCrud;
-        this.hostQuery = hostQuery;
         this.appMonitorQuery = appMonitorQuery;
         this.notifyService = notifyService;
     }
 
     @Override
-    public void add(AppDeployConfig appDeployConfig) {
+    public void init(AppDeployConfig appDeployConfig) {
         AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
         if (appDeploying == null) {
             appDeploying = new AppDeploying(appDeployConfig);
@@ -63,25 +59,42 @@ public class AppDeployingServiceImpl implements AppDeployingService {
     }
 
     @Override
-    public void refresh(DeployLog deployLog) {
+    public void delete(AppDeployConfig appDeployConfig) {
+        AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
+        if (appDeploying != null) {
+            deployingCrud.delete(appDeploying);
+            runningService.delete(appDeploying);
+        }
+    }
+
+    @Override
+    public void refreshBeforeDeploy(AppDeployConfig appDeployConfig, BuildLog buildLog) {
+        String buildLogId = buildLog.getId();
+        String commitId = buildLog.getCommitInfo().getCommitId();
+        String packagePath = buildLog.getPackagePath();
+        String deployBy = buildLog.getBuildBy();
+
+        AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
+        appDeploying.beforeDeploy(buildLogId, commitId, packagePath, deployBy);
+        deployingCrud.update(appDeploying);
+    }
+
+    @Override
+    public void refreshAfterDeploy(DeployLog deployLog) {
         String buildLogId = deployLog.getBuildLogId();
         String machineId = deployLog.getMachineId();
         BuildLog buildLog = buildLogQuery.findById(buildLogId);
         String appId = buildLog.getAppId();
         AppDeploying appDeploying = deployingQuery.findByAppIdAndMachineId(appId, machineId);
         if (appDeploying != null) {
-            appDeploying.updateAfter(deployLog);
+            appDeploying.afterDeploy(deployLog);
             deployingCrud.update(appDeploying);
         }
     }
 
     @Override
-    public void delete(AppDeployConfig appDeployConfig) {
-        AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
-        if (appDeploying != null) {
-            deployingCrud.delete(appDeploying);
-            runningService.delete(appDeploying);
-        }
+    public void addDeployLog(DeployLog deployLog) {
+        deployLogCrud.save(deployLog);
     }
 
     @Override
@@ -89,7 +102,7 @@ public class AppDeployingServiceImpl implements AppDeployingService {
         String buildLogId = deployResult.getBuildLogId();
         String machineId = deployResult.getMachineId();
         DeployLog deployLog = deployLogQuery.findByBuildLogIdAndMachineId(buildLogId, machineId);
-        deployLog.update(deployResult);
+        deployLog.updateAfterDeploy(deployResult);
         deployLogCrud.update(deployLog);
         return deployLog;
     }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java

@@ -61,7 +61,7 @@ public class AppConfigServiceImpl implements AppConfigService {
         }
 
         appConfigCrud.save(appConfig);
-        appBuildingService.add(appConfig);
+        appBuildingService.init(appConfig);
         appMonitorService.add(appConfig);
         String msg = String.format("添加 %s 成功", appConfig.getAppId());
         return Result.result(ResultStatus.SUCCESS, msg);

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployConfigServiceImpl.java

@@ -72,7 +72,7 @@ public class AppDeployConfigServiceImpl implements AppDeployConfigService {
         AppDeployConfig appDeployConfig = new AppDeployConfig(appConfig, machineHost, packType, startScript);
         appDeployConfig = deployConfigCrud.save(appDeployConfig);
 
-        deployingService.add(appDeployConfig);
+        deployingService.init(appDeployConfig);
         return Result.result(ResultStatus.SUCCESS);
     }
 

+ 58 - 96
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployServiceImpl.java

@@ -3,31 +3,28 @@ package cn.reghao.autodop.dmaster.app.service.impl;
 import cn.reghao.autodop.common.mqtt.AsyncMqttClient;
 import cn.reghao.autodop.common.msg.rpc.constant.AppRpcClazz;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployParam;
+import cn.reghao.autodop.common.msg.rpc.dto.app.PackType;
 import cn.reghao.autodop.common.util.thread.ThreadPoolWrapper;
-import cn.reghao.autodop.dmaster.app.db.crud.AppBuildingCrud;
-import cn.reghao.autodop.dmaster.app.db.crud.AppDeployingCrud;
-import cn.reghao.autodop.dmaster.app.db.crud.log.BuildLogCrud;
-import cn.reghao.autodop.dmaster.app.db.query.AppBuildingQuery;
-import cn.reghao.autodop.dmaster.app.db.query.AppDeployingQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
-import cn.reghao.autodop.dmaster.app.model.po.AppBuilding;
-import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.service.AppBuildSupplier;
 import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
 import cn.reghao.autodop.dmaster.app.service.AppDeployer;
 import cn.reghao.autodop.dmaster.app.service.AppBuilder;
-import cn.reghao.autodop.dmaster.notification.service.NotifyService;
-import cn.reghao.autodop.dmaster.spring.interceptor.AppIntegrateReinitInterceptor;
+import cn.reghao.autodop.dmaster.app.service.bd.AppBuildingService;
+import cn.reghao.autodop.dmaster.util.UploadDownload;
+import cn.reghao.autodop.dmaster.spring.HttpRequestUtil;
 import cn.reghao.jdkutil.result.ResultStatus;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.paho.client.mqttv3.MqttException;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
@@ -45,71 +42,55 @@ public class BuildDeployServiceImpl implements BuildDeployService {
     private final Set<String> onBuilding = new ConcurrentSkipListSet<>();
     private final ExecutorService threadPool;
     private final AsyncMqttClient mqttClient;
+    private final AppBuildingService buildingService;
     private final AppDeployer appDeployer;
+    private final UploadDownload uploadDownload;
     private final AppConfigQuery appConfigQuery;
-    private final AppBuildingQuery buildingQuery;
-    private final AppBuildingCrud buildingCrud;
-    private final AppDeployingQuery deployingQuery;
-    private final AppDeployingCrud deployingCrud;
     private final BuildLogQuery buildLogQuery;
-    private final BuildLogCrud buildLogCrud;
 
-    public BuildDeployServiceImpl(AsyncMqttClient mqttClient, AppDeployer appDeployer, AppConfigQuery appConfigQuery,
-                                  AppBuildingQuery buildingQuery, AppBuildingCrud buildingCrud,
-                                  AppDeployingQuery deployingQuery, AppDeployingCrud deployingCrud,
-                                  BuildLogQuery buildLogQuery, BuildLogCrud buildLogCrud) {
+    public BuildDeployServiceImpl(AsyncMqttClient mqttClient, AppDeployer appDeployer,
+                                  AppBuildingService buildingService, UploadDownload uploadDownload,
+                                  AppConfigQuery appConfigQuery, BuildLogQuery buildLogQuery) {
         this.threadPool = ThreadPoolWrapper.threadPool("build-deploy");
         this.mqttClient = mqttClient;
+        this.buildingService = buildingService;
         this.appDeployer = appDeployer;
+        this.uploadDownload = uploadDownload;
         this.appConfigQuery = appConfigQuery;
-        this.buildingQuery = buildingQuery;
-        this.buildingCrud = buildingCrud;
-        this.deployingQuery = deployingQuery;
-        this.deployingCrud = deployingCrud;
         this.buildLogQuery = buildLogQuery;
-        this.buildLogCrud = buildLogCrud;
     }
 
     @Override
-    public String buildAndDeploy(String appId) {
-        build(appId);
-
+    public void buildAndDeploy(String appId) throws Exception {
         if (!onBuilding.add(appId)) {
-            return appId + " 正在构建中";
+            return;
         }
 
         AppConfig app = appConfigQuery.findByAppId(appId);
         if (app == null) {
             onBuilding.remove(appId);
-            //throw new Exception(appId + " 不存在");
+            throw new Exception(appId + " 不存在");
         }
-        AppBuilder appIntegrate = new AppBuilder(app);
 
+        AppBuilder appIntegrate = new AppBuilder(app);
         AppBuildSupplier supplier = new AppBuildSupplier(appIntegrate);
-        log.info("开始异步构建 {}", appId);
+        log.info("{} 开始异步构建", appId);
+        buildingService.refreshBeforeBuild(appId);
         CompletableFuture.supplyAsync(supplier, threadPool)
                 .whenComplete((buildLog, throwable) -> {
+                    if (buildLog != null) {
+                        buildLog = buildingService.addBuildLog(buildLog);
+                        buildingService.refreshAfterBuild(buildLog);
+                    }
+
                     onBuilding.remove(appId);
                     if (throwable != null) {
-                        String msg = throwable.getMessage();
+                        String errMsg = throwable.getMessage();
+                        log.error("{} 构建错误: {}", appId, errMsg);
                         return;
                     }
-
-                    buildLog = buildLogCrud.save(buildLog);
-                    AppBuilding appBuilding = buildingQuery.findByAppId(appId);
-                    if (appBuilding != null) {
-                        appBuilding.update(buildLog);
-                        buildingCrud.save(appBuilding);
-                    }
-
-                    List<AppDeploying> appDeployings = deployingQuery.findByAppId(appId);
-                    if (!appDeployings.isEmpty()) {
-                        for (AppDeploying appDeploying : appDeployings) {
-                            appDeploying.setBuildLogId(buildLog.getId());
-                        }
-                        deployingCrud.saveAll(appDeployings);
-                    }
                     log.info("{} 构建完成", appId);
+                    buildingService.sendBuildNotify(buildLog);
                 })
                 .thenAccept(buildLog -> {
                     if (buildLog.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
@@ -121,72 +102,53 @@ public class BuildDeployServiceImpl implements BuildDeployService {
                         }
                     }
                 });
-        return appId + " 已开始构建";
     }
 
     @Override
-    public String build(String appId) {
-        if (!onBuilding.add(appId)) {
-            return appId + " 正在构建中";
-        }
-
-        AppConfig app = appConfigQuery.findByAppId(appId);
-        if (app == null) {
-            onBuilding.remove(appId);
-            //throw new Exception(appId + " 不存在");
-        }
-
-        AppBuilder appIntegrate = new AppBuilder(app);
-        AppBuildSupplier supplier = new AppBuildSupplier(appIntegrate);
-        log.info("开始异步构建 {}", appId);
-        CompletableFuture.supplyAsync(supplier, threadPool)
-                .whenComplete((buildLog, throwable) -> {
-                    onBuilding.remove(appId);
-                    if (throwable != null) {
-                        String msg = throwable.getMessage();
-                        return;
-                    }
-
-                    buildLog = buildLogCrud.save(buildLog);
-                    AppBuilding appBuilding = buildingQuery.findByAppId(appId);
-                    if (appBuilding != null) {
-                        appBuilding.update(buildLog);
-                        buildingCrud.save(appBuilding);
-                    }
-
-                    List<AppDeploying> appDeployings = deployingQuery.findByAppId(appId);
-                    if (!appDeployings.isEmpty()) {
-                        for (AppDeploying appDeploying : appDeployings) {
-                            appDeploying.setBuildLogId(buildLog.getId());
-                        }
-                        deployingCrud.saveAll(appDeployings);
-                    }
-                    log.info("{} 构建完成", appId);
-                })
-                .thenAccept(buildLog -> {
-                });
-        return appId + " 已开始构建";
+    public void build(String appId) {
     }
 
     @Override
-    public boolean deploy(String buildLogId) {
-        return false;
+    public void deploy(String buildLogId) {
     }
 
     @Override
-    public void downloadPackage(String buildLogId) {
+    public void downloadPackage(String buildLogId) throws Exception {
         BuildLog buildLog = buildLogQuery.findById(buildLogId);
         if (buildLog == null) {
-            String msg = "构建不存在";
-            return;
+            String errMsg = "构建不存在";
+            throw new Exception(errMsg);
         }
 
-        String packagePath = buildLog.getPackagePath();
+        String appId = buildLog.getAppId();
+        AppConfig appConfig = appConfigQuery.findByAppId(appId);
+        if (appConfig == null) {
+            String errMsg = "应用不存在";
+            throw new Exception(errMsg);
+        }
+
+        String packType = appConfig.getPackerConfig().getType();
+        switch (PackType.valueOf(packType)) {
+            case docker:
+                String errMsg = "docker 打包类型的应用不能下载";
+                throw new Exception(errMsg);
+            case zip:
+                String packagePath = buildLog.getPackagePath();
+                String filename = packagePath.substring(packagePath.lastIndexOf(File.separator)+1);
+                FileInputStream fileInputStream = new FileInputStream(packagePath);
+                BufferedInputStream bis = new BufferedInputStream(fileInputStream);
+                uploadDownload.download(filename, bis, HttpRequestUtil.getResponse());
+                break;
+            case zipHttp:
+                throw new Exception(String.format("打包类型 %s 暂未实现", packType));
+            default:
+                throw new Exception(String.format("打包类型 %s 不存在", packType));
+        }
     }
 
     @Override
     public List<String> currentlyBuilding() {
-        return Collections.emptyList();
+        return List.copyOf(onBuilding);
     }
 
     @Override

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/util/buildtool/packer/ZipPack.java

@@ -17,9 +17,9 @@ public class ZipPack implements CodePacker {
     private final String targetPath;
     private final String binfilesDirname;
 
-    public ZipPack(PackerConfig packerConfig) {
+    public ZipPack(PackerConfig packerConfig, String appPackDir) {
         this.targetPath = packerConfig.getType().equals(PackType.zip.getName()) ?
-                LocalBuildDir.packDir : packerConfig.getTargetPath();
+                appPackDir : packerConfig.getTargetPath();
         this.binfilesDirname = packerConfig.getBinfilesDirname();
     }
 

+ 4 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/model/dto/AppMonitorDto.java

@@ -1,6 +1,7 @@
 package cn.reghao.autodop.dmaster.monitor.model.dto;
 
 import cn.reghao.autodop.dmaster.monitor.model.po.AppMonitor;
+import cn.reghao.autodop.common.util.NotAvailable;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -24,9 +25,9 @@ public class AppMonitorDto implements Serializable {
     public AppMonitorDto(AppMonitor appMonitor) {
         this.appId = appMonitor.getAppConfig().getAppId();
         this.appName = appMonitor.getAppConfig().getAppName();
-        this.appBuild = appMonitor.getAppBuild() != null ? appMonitor.getAppBuild().getNotifyAccountId() : "N/A";
-        this.appDeploy = appMonitor.getAppDeploy() != null ? appMonitor.getAppDeploy().getNotifyAccountId() : "N/A";
+        this.appBuild = appMonitor.getAppBuild() != null ? appMonitor.getAppBuild().getNotifyAccountId() : NotAvailable.na.getDesc();
+        this.appDeploy = appMonitor.getAppDeploy() != null ? appMonitor.getAppDeploy().getNotifyAccountId() : NotAvailable.na.getDesc();
         this.appHealthCheck = appMonitor.getAppHealthCheck() != null ?
-                appMonitor.getAppHealthCheck().getNotifyAccountId() : "N/A";
+                appMonitor.getAppHealthCheck().getNotifyAccountId() : NotAvailable.na.getDesc();
     }
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/impl/rpcresult/AppRpcClazzResultImpl.java

@@ -30,7 +30,7 @@ public class AppRpcClazzResultImpl {
         // 1.更新 DeployLog
         DeployLog deployLog = deployingService.updateDeployLog(deployResult);
         // 2.更新 AppDeploying
-        deployingService.refresh(deployLog);
+        deployingService.refreshAfterDeploy(deployLog);
         // 3.更新 AppRunning
         Result result = deployResult.getResult();
         int code = result.getCode();

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/util/db/HttpRequestUtil.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/HttpRequestUtil.java

@@ -1,4 +1,4 @@
-package cn.reghao.autodop.dmaster.util.db;
+package cn.reghao.autodop.dmaster.spring;
 
 import org.springframework.util.StringUtils;
 import org.springframework.web.context.request.RequestContextHolder;

+ 4 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/interceptor/AppIntegrateReinitInterceptor.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/interceptor/AppConfigInterceptor.java

@@ -12,7 +12,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentSkipListSet;
 
 /**
- * TODO 若 AppOrchestration 发生修改,则重新初始化 AppIntegrate
+ * TODO 若 AppConfig 发生修改,则重新初始化 AppIntegrate
  *
  * @author reghao
  * @date 2020-03-06 16:04:27
@@ -20,10 +20,10 @@ import java.util.concurrent.ConcurrentSkipListSet;
 @Slf4j
 @Component
 @Aspect
-public class AppIntegrateReinitInterceptor {
+public class AppConfigInterceptor {
     private Set<String> changedApp = new ConcurrentSkipListSet<>();
-    // 拦截 cn.reghao.autodop.dmaster.app.db 包中的所有方法
-    private final static String POINT = "execution (* cn.reghao.autodop.dmaster.app.db..*.*(..))";
+    // 拦截 cn.reghao.autodop.dmaster.app.db.crud.config 包中的所有方法
+    private final static String POINT = "execution (* cn.reghao.autodop.dmaster.app.db.crud.config..*.*(..))";
 
     @Pointcut(POINT)
     public void reinit(){

+ 1 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/util/db/PageSort.java

@@ -1,5 +1,6 @@
 package cn.reghao.autodop.dmaster.util.db;
 
+import cn.reghao.autodop.dmaster.spring.HttpRequestUtil;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
 

+ 3 - 3
dmaster/src/main/resources/templates/app/bd/index.html

@@ -99,10 +99,10 @@
 
     $(".build-result").each(function () {
         var text = $(this).text().trim()
-        if (text === '成功') {
-            $(this).css("color", "#009688")
-        } else {
+        if (text === '构建失败') {
             $(this).css("color", "#ff0000")
+        } else {
+            $(this).css("color", "#009688")
         }
     })
 </script>