|
@@ -146,7 +146,20 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
String appId = appDeployConfig.getAppConfig().getAppId();
|
|
String appId = appDeployConfig.getAppConfig().getAppId();
|
|
|
String machineId = appDeployConfig.getMachineHost().getMachineId();
|
|
String machineId = appDeployConfig.getMachineHost().getMachineId();
|
|
|
if (!isRunning(appId, machineId)) {
|
|
if (!isRunning(appId, machineId)) {
|
|
|
- deployingRepository.deleteByAppConfig_AppId(appId);
|
|
|
|
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
|
|
+ List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
|
|
|
+ int index = getIndex(deployingNodes, machineId);
|
|
|
|
|
+ if (index != -1) {
|
|
|
|
|
+ deployingNodes.remove(index);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (deployingNodes.size() == 0) {
|
|
|
|
|
+ deployingRepository.deleteByAppConfig_AppId(appId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ appDeploying.setDeployingNodes(deployingNodes);
|
|
|
|
|
+ deployingRepository.save(appDeploying);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
deployLogRepository.deleteByMachineHost_MachineId(machineId);
|
|
deployLogRepository.deleteByMachineHost_MachineId(machineId);
|
|
|
deployConfigRepository.delete(appDeployConfig);
|
|
deployConfigRepository.delete(appDeployConfig);
|
|
|
return Result.result(ResultStatus.SUCCESS);
|
|
return Result.result(ResultStatus.SUCCESS);
|
|
@@ -161,7 +174,8 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
|
|
for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
|
|
|
String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
if (machineId.equals(machineId1)) {
|
|
if (machineId.equals(machineId1)) {
|
|
|
- return deployingNode.getRunning();
|
|
|
|
|
|
|
+ int pid = deployingNode.getPid();
|
|
|
|
|
+ return pid != -1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -214,14 +228,7 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
if (appDeploying != null) {
|
|
if (appDeploying != null) {
|
|
|
List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
|
|
|
|
|
|
- int idx = -1;
|
|
|
|
|
- for (int i = 0; i < deployingNodes.size(); i++) {
|
|
|
|
|
- String machineId1 = deployingNodes.get(i).getDeployConfig().getMachineHost().getMachineId();
|
|
|
|
|
- if (machineId.equals(machineId1)) {
|
|
|
|
|
- idx = i;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ int idx = getIndex(deployingNodes, machineId);
|
|
|
if (idx != -1) {
|
|
if (idx != -1) {
|
|
|
deployingNodes.remove(idx);
|
|
deployingNodes.remove(idx);
|
|
|
deployLogRepository.deleteByMachineHost_MachineId(machineId);
|
|
deployLogRepository.deleteByMachineHost_MachineId(machineId);
|
|
@@ -230,6 +237,19 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private int getIndex(List<AppDeployingNode> deployingNodes, String machineId) {
|
|
|
|
|
+ int idx = -1;
|
|
|
|
|
+ for (int i = 0; i < deployingNodes.size(); i++) {
|
|
|
|
|
+ String machineId1 = deployingNodes.get(i).getDeployConfig().getMachineHost().getMachineId();
|
|
|
|
|
+ if (machineId.equals(machineId1)) {
|
|
|
|
|
+ idx = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return idx;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void updateAfterBuild(AppBuilding appBuilding) {
|
|
public void updateAfterBuild(AppBuilding appBuilding) {
|
|
|
AppConfig appConfig = appBuilding.getAppConfig();
|
|
AppConfig appConfig = appBuilding.getAppConfig();
|