use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method getByServerDeployHistoryId.
@Override
public DeployHistory getByServerDeployHistoryId(int serverDeployHistoryId) {
ServerDeployHistoryPO po = serverDeployHistoryDao.get(serverDeployHistoryId);
DeployHistory history = null;
if (po != null) {
DeployHistoryPO deployPo = deployHistoryDao.get(po.getHistoryId());
history = new DeployHistory();
VOUtil.copy(deployPo, history);
}
return history;
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method createRollbackOrder.
@Override
public void createRollbackOrder(int historyId, long accountId, boolean isRollBack) {
DeployHistory deployHistory = getByHistoryId(historyId);
if (deployHistory == null) {
throw new IllegalArgumentException("发布记录不存在");
}
AdminAccount account = adminAccountService.getById(accountId);
DeploymentOrder order = new DeploymentOrder();
VOUtil.copy(deployHistory, order);
order.setAccountId(accountId);
order.setRealName(account.getRealname());
List<ServerDeployHistory> serverDeployHistories = deployHistory.getServerDeployHistories();
int[] serverId = new int[serverDeployHistories.size()];
for (int i = 0; i < serverId.length; i++) {
serverId[i] = serverDeployHistories.get(i).getServerId();
}
order.setServerId(serverId);
order.setRollbackToDeployId(historyId);
if (isRollBack) {
order.setTitle("回滚到" + historyId + "的版本");
} else {
order.setTitle("重发" + historyId + "的版本");
}
createDeploymentOrder(order);
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class PushStepLogToClientThread method run.
@Override
public void run() {
logger.info("推送步骤日志线程已启动 ...");
Map<Integer, Long> historyId2StepLogCountMap = new LRUMap();
Map<Integer, Long> historyId2ServerLogCountMap = new LRUMap();
List<ClearLogReq> clearLogReqs = new ArrayList<>();
running = true;
while (running) {
try {
Map<String, String> allModules = moduleStatusManagementService.getAllDeployingModules();
for (Map.Entry<String, String> entry : allModules.entrySet()) {
int historyId = moduleStatusManagementService.getHistoryIdFromFieldValue(entry.getValue());
if (historyId <= 0) {
continue;
}
DeployHistory deployHistory = deployHistoryService.getByHistoryId(historyId);
if (deployHistory == null) {
continue;
}
String stepLogKey = RedisKey.getProjectHistoryLogKey(historyId);
List<String> stepLogs = buildLogList(historyId2StepLogCountMap, stepLogKey, historyId);
String serverLogKey = RedisLogKey.getDeployServerLogKey(historyId);
List<String> serverDeployLogs = buildLogList(historyId2ServerLogCountMap, serverLogKey, historyId);
String logMessage = buildClientLogMessage(stepLogs, serverDeployLogs);
if (CollectionUtils.isNotEmpty(stepLogs) || CollectionUtils.isNotEmpty(serverDeployLogs)) {
sendLogToClient(deployHistory, logMessage);
} else {
logger.info("没有日志推送, historyId: " + historyId);
}
if (deployHistory.getDeployStatus() == DeployStatus.DEPLOYED.getValue()) {
clearLogReqs.add(new ClearLogReq(historyId, deployHistory.getModuleId(), deployHistory.getEnvId()));
}
}
clearModuleDeployLog(clearLogReqs);
} catch (Exception e) {
logger.error("日志推送异常", e);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
logger.warn("线程 Interrupted");
break;
}
}
logger.info("推送步骤日志线程退出 ...");
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class ViewDeployHistoryController method getDeployHistory.
@RequestMapping("getDeployHistory")
@ResponseBody
@MenuResource("发布详情")
public RestResult<DeployHistory> getDeployHistory(int historyId) {
long accountId = AdminContext.getAccountId();
DeployHistory deployHistory = deployHistoryService.getByHistoryId(historyId);
if (deployHistory == null) {
return new RestResult<>(ApiCode.FAILURE, "找不到发布记录");
}
return new RestResult<>(deployHistory);
}
use of com.ibeiliao.deployment.admin.vo.deploy.DeployHistory in project Corgi by kevinYin.
the class ViewProjectController method createTransferRequest.
private TransferRequest createTransferRequest(int serverId, boolean restart) throws Exception {
Server server = serverService.getById(serverId);
Assert.notNull(server, "server不存在");
ServerGroup serverGroup = serverGroupService.getById(server.getGroupId());
Assert.notNull(serverGroup, "serverGroup不存在");
ProjectModule module = projectModuleService.getByModuleId(serverGroup.getModuleId());
Project project = projectService.getProject(module.getProjectId());
ProjectEnv env = projectEnvService.getById(serverGroup.getEnvId());
long accountId = AdminContext.getAccountId();
// if (projectAccountRelationService.canModify(accountId, project.getProjectId())) {
DeployHistory deployHistory = null;
if (restart) {
deployHistory = deployHistoryService.createRestartHistory(accountId, serverId);
} else {
deployHistory = deployHistoryService.createStopHistory(accountId, serverId);
}
TransferRequest request = new TransferRequest();
request.setHistoryId(deployHistory.getHistoryId());
request.setSaveFileName(null);
request.setModuleName(module.getModuleName());
request.setEnv(env.getEnvName());
request.setProjectName(project.getProjectNo());
request.setRestartShell(module.getRestartShell());
request.setJvmArgs(getModuleJvmArgs(module.getModuleId(), serverGroup.getEnvId()));
request.setPreDeployShell(module.getPreShell());
request.setPostDeployShell(module.getPostShell());
request.setStopShell(module.getStopShell());
request.setModuleType(module.getModuleType());
List<String> serverIps = new ArrayList<>();
serverIps.add(server.getIp());
request.setTargetServerIps(serverIps);
if (module.getModuleType() == ModuleType.WEB_PROJECT.getValue()) {
ResinConf resinConf = module.getResinConf();
// 设置 [当前环境] 的域名
resinConf.setDomain(ModuleUtil.getDomainForEnv(resinConf.getDomain(), env.getEnvName()));
resinConf.setAliasDomain(ModuleUtil.getAliasDomainForEnv(resinConf.getAliasDomain(), env.getEnvName()));
request.setModuleFinalName(readFinalName(module, deployHistory.getTagName()));
request.setResinConf(resinConf);
if (!projectModuleService.isResinConfCreated(deployHistory.getModuleId()) || resinConf.isCreateEveryTime()) {
request.setCreateResinConf(true);
}
}
return request;
// }
// throw new IllegalStateException("你没有权限操作,请联系项目负责人或超级管理员");
}
Aggregations