Procházet zdrojové kódy

AppDeployingNode 中的 String status 字段修改为 Boolean running, 使用 boolean 值来表示 app 是否处于运行状态

reghao před 1 rokem
rodič
revize
6c2132139e

+ 3 - 2
common/src/main/java/cn/reghao/devops/common/agent/app/iface/impl/DockerApp.java

@@ -106,12 +106,13 @@ public class DockerApp {
 
         InspectContainerResponse.ContainerState state = containerInfo.getState();
         if (state == null || Boolean.FALSE.equals(state.getRunning())) {
-            appStatResult.setStatus(NodeStatus.Offline.name());
+            //appStatResult.setStatus(NodeStatus.Offline.name());
             appStatResult.setStartTime(null);
             appStatResult.setPid(-1);
         } else {
             String startedAt = state.getStartedAt();
-            appStatResult.setStatus(NodeStatus.Online.name());
+            //appStatResult.setStatus(NodeStatus.Online.name());
+            appStatResult.setRunning(true);
             appStatResult.setStartTime(DateTimeConverter.localDateTime(startedAt));
             appStatResult.setPid(state.getPidLong().intValue());
         }

+ 2 - 1
common/src/main/java/cn/reghao/devops/common/msg/event/EvtAppStatResult.java

@@ -17,7 +17,7 @@ public class EvtAppStatResult extends Event {
     private String machineId;
     private String appId;
     private String commitId;
-    private String status;
+    private Boolean running;
     private LocalDateTime startTime;
     private Integer pid;
     private Boolean deploy;
@@ -26,6 +26,7 @@ public class EvtAppStatResult extends Event {
     public EvtAppStatResult(String appId, String machineId) {
         this.appId = appId;
         this.machineId = machineId;
+        this.running = false;
         this.deploy = false;
     }
 }

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/app/model/po/AppDeployingNode.java

@@ -31,7 +31,7 @@ public class AppDeployingNode implements Serializable {
     private boolean deployed;
 
     // AppRunning
-    private String status;
+    private Boolean running;
     private LocalDateTime startTime;
     private Integer pid;
     private LocalDateTime lastCheck;
@@ -44,7 +44,7 @@ public class AppDeployingNode implements Serializable {
         this.onDeploying = false;
         this.deployed = false;
 
-        this.status = NotAvailable.na.getDesc();
+        this.running = false;
         this.startTime = DateTimeConverter.localDateTime(0);
         this.pid = -1;
         this.lastCheck = DateTimeConverter.localDateTime(0);

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/app/model/vo/AppRunning.java

@@ -38,13 +38,13 @@ public class AppRunning {
 
         if (buildLog != null) {
             this.packagePath = buildLog.getPackagePath();
-            this.status = deployingNode.getStatus();
+            this.status = deployingNode.getRunning() ? "运行中" : "未运行";
             this.startTime = DateTimeConverter.format(deployingNode.getStartTime());
             this.pid = deployingNode.getPid();
             this.lastCheck = DateTimeConverter.format(deployingNode.getLastCheck());
         } else {
             this.packagePath = NotAvailable.na.getDesc();
-            this.status = NotAvailable.na.getDesc();
+            this.status = "未运行";
             this.startTime = NotAvailable.na.getDesc();
             this.pid = -1;
             this.lastCheck = NotAvailable.na.getDesc();

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/app/service/impl/AppDeployServiceImpl.java

@@ -243,7 +243,7 @@ public class AppDeployServiceImpl implements AppDeployService {
                 deployNode.setDeployTime(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
                 if (deployResult.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
                     deployNode.setDeployResult(DeployStatus.deploySuccess.getDesc());
-                    deployNode.setStatus(deployResult.getStatus());
+                    deployNode.setRunning(deployResult.getRunning());
                     deployNode.setStartTime(deployResult.getStartTime());
                     deployNode.setPid(deployResult.getPid());
                     deployNode.setLastCheck(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
@@ -273,7 +273,7 @@ public class AppDeployServiceImpl implements AppDeployService {
             appDeploying.getDeployingNodes().forEach(appDeployingNode -> {
                 String machineId1 = appDeployingNode.getDeployConfig().getMachineHost().getMachineId();
                 if (machineId1.equals(machineId)) {
-                    appDeployingNode.setStatus(statResult.getStatus());
+                    appDeployingNode.setRunning(statResult.getRunning());
                     appDeployingNode.setStartTime(statResult.getStartTime());
                     appDeployingNode.setPid(statResult.getPid());
                     appDeployingNode.setLastCheck(DateTimeConverter.localDateTime(statResult.getResult().getTimestamp()));

+ 1 - 1
web/src/main/resources/templates/devops/app/stat/index2.html

@@ -45,7 +45,7 @@
 <script type="text/javascript">
     $(".app-status").each(function () {
         var text = $(this).text().trim()
-        if (text === 'Online') {
+        if (text === '运行中') {
             $(this).css("color", "#009688")
         } else {
             $(this).css("color", "#ff0000")