|
|
@@ -134,15 +134,51 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Result deleteDeployConfig(int appDeployConfigId) {
|
|
|
- deployConfigRepository.deleteById(appDeployConfigId);
|
|
|
+ AppDeployConfig appDeployConfig = deployConfigRepository.findById(appDeployConfigId).orElse(null);
|
|
|
+ if (appDeployConfig == null) {
|
|
|
+ return Result.result(ResultStatus.FAIL, "AppDeployConfig not exists");
|
|
|
+ }
|
|
|
|
|
|
- /*AppDeployConfig appDeployConfig = deployConfigQuery.findById(appDeployConfigId);
|
|
|
+ return deleteAppDeployConfig(appDeployConfig);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Result deleteAppDeployConfig(AppDeployConfig appDeployConfig) {
|
|
|
String appId = appDeployConfig.getAppConfig().getAppId();
|
|
|
String machineId = appDeployConfig.getMachineHost().getMachineId();
|
|
|
if (!isRunning(appId, machineId)) {
|
|
|
- delete(appDeployConfig);
|
|
|
+ deployingRepository.deleteByAppConfig_AppId(appId);
|
|
|
+ deployLogRepository.deleteByMachineHost_MachineId(machineId);
|
|
|
deployConfigRepository.delete(appDeployConfig);
|
|
|
- }*/
|
|
|
+ return Result.result(ResultStatus.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.result(ResultStatus.FAIL, "app is running");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isRunning(String appId, String machineId) {
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
+ if (appDeploying != null) {
|
|
|
+ for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
|
|
|
+ String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
+ if (machineId.equals(machineId1)) {
|
|
|
+ int pid = deployingNode.getPid();
|
|
|
+ return pid != -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result deleteByApp(String appId) {
|
|
|
+ List<AppDeployConfig> list = deployConfigRepository.findByAppConfig_AppId(appId);
|
|
|
+ for (AppDeployConfig appDeployConfig : list) {
|
|
|
+ Result result = deleteAppDeployConfig(appDeployConfig);
|
|
|
+ if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return Result.result(ResultStatus.SUCCESS);
|
|
|
}
|
|
|
@@ -289,20 +325,4 @@ public class AppDeployServiceImpl implements AppDeployService {
|
|
|
log.info("{} -> {} not exist", machineIpv4, appId);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Deprecated
|
|
|
- public boolean isRunning(String appId, String machineId) {
|
|
|
- AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
- if (appDeploying != null) {
|
|
|
- for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
|
|
|
- String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
|
|
|
- if (machineId.equals(machineId1)) {
|
|
|
- int pid = deployingNode.getPid();
|
|
|
- return pid != -1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
}
|