|
|
@@ -95,6 +95,12 @@ public class DeployStatImpl implements DeployStat {
|
|
|
AppConfig appConfig = appBuilding.getAppConfig();
|
|
|
AppDeploying appDeploying = deployingRepository.findByAppConfig(appConfig);
|
|
|
if (appDeploying != null) {
|
|
|
+ appDeploying.getDeployingNodes().forEach(deployNode -> {
|
|
|
+ deployNode.setDeployResult(DeployStatus.neverDeploy.getDesc());
|
|
|
+ deployNode.setOnDeploying(false);
|
|
|
+ deployNode.setDeployed(false);
|
|
|
+ });
|
|
|
+
|
|
|
appDeploying.setBuildLog(appBuilding.getBuildLog());
|
|
|
deployingRepository.save(appDeploying);
|
|
|
}
|
|
|
@@ -104,15 +110,16 @@ public class DeployStatImpl implements DeployStat {
|
|
|
public void beforeDeploy(AppBuilding appBuilding, String machineId, String deployBy) {
|
|
|
AppDeploying appDeploying = deployingRepository.findByAppConfig(appBuilding.getAppConfig());
|
|
|
appDeploying.setBuildLog(appBuilding.getBuildLog());
|
|
|
- for (AppDeployingNode deployNode : appDeploying.getDeployingNodes()) {
|
|
|
- String machineId1 = deployNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
+ appDeploying.getDeployingNodes().forEach(appDeployingNode -> {
|
|
|
+ String machineId1 = appDeployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
if (machineId1.equals(machineId)) {
|
|
|
- deployNode.setDeployResult(DeployStatus.onDeploying.getDesc());
|
|
|
- deployNode.setDeployBy(deployBy);
|
|
|
- deployNode.setOnDeploying(true);
|
|
|
- deployNode.setDeployed(false);
|
|
|
+ appDeployingNode.setDeployResult(DeployStatus.onDeploying.getDesc());
|
|
|
+ appDeployingNode.setDeployBy(deployBy);
|
|
|
+ appDeployingNode.setOnDeploying(true);
|
|
|
+ appDeployingNode.setDeployed(false);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
deployingRepository.save(appDeploying);
|
|
|
}
|
|
|
|
|
|
@@ -122,15 +129,20 @@ public class DeployStatImpl implements DeployStat {
|
|
|
String machineId = deployResult.getMachineId();
|
|
|
String appId = deployResult.getAppId();
|
|
|
AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
- for (AppDeployingNode deployNode : appDeploying.getDeployingNodes()) {
|
|
|
+ appDeploying.getDeployingNodes().forEach(deployNode -> {
|
|
|
String machineId1 = deployNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
if (machineId1.equals(machineId)) {
|
|
|
- appDeploying.afterDeploy(deployResult);
|
|
|
+ deployNode.setOnDeploying(false);
|
|
|
+ deployNode.setDeployed(true);
|
|
|
+ deployNode.setDeployTime(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
|
|
|
if (deployResult.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
|
|
|
+ deployNode.setDeployResult(DeployStatus.deploySuccess.getDesc());
|
|
|
deployNode.setStatus(deployResult.getStatus());
|
|
|
deployNode.setStartTime(deployResult.getStartTime());
|
|
|
deployNode.setPid(deployResult.getPid());
|
|
|
deployNode.setLastCheck(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
|
|
|
+ } else {
|
|
|
+ deployNode.setDeployResult(DeployStatus.deployFail.getDesc());
|
|
|
}
|
|
|
|
|
|
MachineHost machineHost = deployNode.getDeployConfig().getMachineHost();
|
|
|
@@ -141,13 +153,29 @@ public class DeployStatImpl implements DeployStat {
|
|
|
buildDeployNotify.deployNotify(deployLog);
|
|
|
log.info("{} 的通知已发送", deployResult.getAppId());
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
deployingRepository.save(appDeploying);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void refresh(EvtAppStatResult statResult) {
|
|
|
+ String appId = statResult.getAppId();
|
|
|
+ String machineId = statResult.getMachineId();
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
+ if (appDeploying != null) {
|
|
|
+ appDeploying.getDeployingNodes().forEach(appDeployingNode -> {
|
|
|
+ String machineId1 = appDeployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
+ if (machineId1.equals(machineId)) {
|
|
|
+ appDeployingNode.setStatus(statResult.getStatus());
|
|
|
+ appDeployingNode.setStartTime(statResult.getStartTime());
|
|
|
+ appDeployingNode.setPid(statResult.getPid());
|
|
|
+ appDeployingNode.setLastCheck(DateTimeConverter.localDateTime(statResult.getResult().getTimestamp()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ deployingRepository.save(appDeploying);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -178,12 +206,7 @@ public class DeployStatImpl implements DeployStat {
|
|
|
MachineHost machineHost = appDeployingNode.getDeployConfig().getMachineHost();
|
|
|
String machineStatus = machineService.isAgentOnline(machineHost.getMachineId())
|
|
|
? NodeStatus.Online.name() : NodeStatus.Offline.name();
|
|
|
-
|
|
|
- if (buildLog == null || buildLog.getCode() != ResultStatus.SUCCESS.getCode()) {
|
|
|
- return new AppDeployingVO(appDeployingNode, null, machineStatus);
|
|
|
- }
|
|
|
-
|
|
|
- return new AppDeployingVO(appDeployingNode, buildLog, machineStatus, DeployStatus.neverDeploy.getDesc());
|
|
|
+ return new AppDeployingVO(appDeployingNode, buildLog, machineStatus);
|
|
|
}).sorted(Comparator.comparing(AppDeployingVO::getDeployTime).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
|