|
@@ -7,10 +7,12 @@ import cn.reghao.autodop.common.util.thread.ThreadPoolWrapper;
|
|
|
import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
|
|
import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
|
|
|
import cn.reghao.autodop.dmaster.app.db.query.config.AppDeployConfigQuery;
|
|
import cn.reghao.autodop.dmaster.app.db.query.config.AppDeployConfigQuery;
|
|
|
import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
|
|
import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.db.query.log.DeployLogQuery;
|
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
|
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
|
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
|
|
import cn.reghao.autodop.dmaster.app.model.po.config.build.LocalBuildDir;
|
|
|
import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
|
|
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.app.service.AppBuildSupplier;
|
|
import cn.reghao.autodop.dmaster.app.service.AppBuildSupplier;
|
|
|
import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
|
|
import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
|
|
|
import cn.reghao.autodop.dmaster.app.service.AppDeployer;
|
|
import cn.reghao.autodop.dmaster.app.service.AppDeployer;
|
|
@@ -46,12 +48,13 @@ public class BuildDeployServiceImpl implements BuildDeployService {
|
|
|
private final UploadDownload uploadDownload;
|
|
private final UploadDownload uploadDownload;
|
|
|
private final AppConfigQuery appConfigQuery;
|
|
private final AppConfigQuery appConfigQuery;
|
|
|
private final BuildLogQuery buildLogQuery;
|
|
private final BuildLogQuery buildLogQuery;
|
|
|
- private AppDeployConfigQuery deployConfigQuery;
|
|
|
|
|
|
|
+ private final AppDeployConfigQuery deployConfigQuery;
|
|
|
|
|
+ private final DeployLogQuery deployLogQuery;
|
|
|
|
|
|
|
|
public BuildDeployServiceImpl(AsyncMqttClient mqttClient, AppDeployer appDeployer,
|
|
public BuildDeployServiceImpl(AsyncMqttClient mqttClient, AppDeployer appDeployer,
|
|
|
AppBuildingService buildingService, UploadDownload uploadDownload,
|
|
AppBuildingService buildingService, UploadDownload uploadDownload,
|
|
|
AppConfigQuery appConfigQuery, BuildLogQuery buildLogQuery,
|
|
AppConfigQuery appConfigQuery, BuildLogQuery buildLogQuery,
|
|
|
- AppDeployConfigQuery deployConfigQuery) {
|
|
|
|
|
|
|
+ AppDeployConfigQuery deployConfigQuery, DeployLogQuery deployLogQuery) {
|
|
|
this.threadPool = ThreadPoolWrapper.threadPool("build-deploy");
|
|
this.threadPool = ThreadPoolWrapper.threadPool("build-deploy");
|
|
|
this.mqttClient = mqttClient;
|
|
this.mqttClient = mqttClient;
|
|
|
this.buildingService = buildingService;
|
|
this.buildingService = buildingService;
|
|
@@ -60,6 +63,7 @@ public class BuildDeployServiceImpl implements BuildDeployService {
|
|
|
this.appConfigQuery = appConfigQuery;
|
|
this.appConfigQuery = appConfigQuery;
|
|
|
this.buildLogQuery = buildLogQuery;
|
|
this.buildLogQuery = buildLogQuery;
|
|
|
this.deployConfigQuery = deployConfigQuery;
|
|
this.deployConfigQuery = deployConfigQuery;
|
|
|
|
|
+ this.deployLogQuery = deployLogQuery;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -92,7 +96,9 @@ public class BuildDeployServiceImpl implements BuildDeployService {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
log.info("{} 构建完成", appId);
|
|
log.info("{} 构建完成", appId);
|
|
|
- buildingService.sendBuildNotify(buildLog);
|
|
|
|
|
|
|
+ if (!isDeploy) {
|
|
|
|
|
+ buildingService.sendBuildNotify(buildLog);
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("构建后处理发生错误: {}", ExceptionUtil.errorMsg(e));
|
|
log.error("构建后处理发生错误: {}", ExceptionUtil.errorMsg(e));
|
|
|
} finally {
|
|
} finally {
|
|
@@ -112,6 +118,7 @@ public class BuildDeployServiceImpl implements BuildDeployService {
|
|
|
String errMsg = ExceptionUtil.errorMsg(e);
|
|
String errMsg = ExceptionUtil.errorMsg(e);
|
|
|
log.error("部署 {} 时抛出异常: {}", appId, errMsg);
|
|
log.error("部署 {} 时抛出异常: {}", appId, errMsg);
|
|
|
} finally {
|
|
} finally {
|
|
|
|
|
+ // TODO RPC 异步调用返回后部署才算完成
|
|
|
onDeploying.remove(appId);
|
|
onDeploying.remove(appId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -120,11 +127,12 @@ public class BuildDeployServiceImpl implements BuildDeployService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void deploy(String buildLogId, String machineId) throws MqttException {
|
|
public void deploy(String buildLogId, String machineId) throws MqttException {
|
|
|
- BuildLog buildLog = buildLogQuery.findById(buildLogId);
|
|
|
|
|
- if (buildLog == null) {
|
|
|
|
|
|
|
+ DeployLog deployLog = deployLogQuery.findByBuildLogIdAndMachineId(buildLogId, machineId);
|
|
|
|
|
+ if (deployLog != null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ BuildLog buildLog = buildLogQuery.findById(buildLogId);
|
|
|
String appId = buildLog.getAppId();
|
|
String appId = buildLog.getAppId();
|
|
|
if (!onDeploying.add(appId)) {
|
|
if (!onDeploying.add(appId)) {
|
|
|
return;
|
|
return;
|