Search in sources :

Example 11 with DeployHistory

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;
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 12 with DeployHistory

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);
}
Also used : ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) DeploymentOrder(com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 13 with DeployHistory

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("推送步骤日志线程退出 ...");
}
Also used : DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) LRUMap(org.apache.commons.collections.map.LRUMap) LRUMap(org.apache.commons.collections.map.LRUMap)

Example 14 with DeployHistory

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);
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with 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("你没有权限操作,请联系项目负责人或超级管理员");
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ArrayList(java.util.ArrayList) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest)

Aggregations

DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)20 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)14 Test (org.junit.Test)6 InitTestDataService (com.ibeiliao.deployment.admin.service.InitTestDataService)4 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)3 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)2 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 Date (java.util.Date)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DeployHistoryService (com.ibeiliao.deployment.admin.service.deploy.DeployHistoryService)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 ShellLogRequestMessage (com.ibeiliao.deployment.admin.websocket.request.ShellLogRequestMessage)1 ShellLogResponseMessage (com.ibeiliao.deployment.admin.websocket.request.ShellLogResponseMessage)1 Redis (com.ibeiliao.deployment.common.util.redis.Redis)1