Search in sources :

Example 1 with TransferRequest

use of com.ibeiliao.deployment.transfer.vo.TransferRequest in project Corgi by kevinYin.

the class TestTransfer method testTransform.

@Test
public void testTransform() {
    TransferRequest transferRequest = new TransferRequest();
    transferRequest.setHistoryId(20);
    transferRequest.setSaveFileName("dev/statement-impl.tar.gz");
    transferRequest.setModuleName("statement-impl");
    transferRequest.setEnv("dev");
    transferRequest.setModuleType(ModuleType.SERVICE.getValue());
    transferRequest.setTargetServerIps(Lists.newArrayList("123.56.158.175"));
    transferRequest.setProjectName("pay");
    transferRequest.setRestartShell("com.alibaba.dubbo.container.Main");
    transferRequest.setJvmArgs("-Xms128m -Xmx192m -server -d64");
    // 发布  重启  stop
    JavaTransferService javaTransferService = new JavaTransferService(transferRequest, DeployType.STOP);
    javaTransferService.pushPackageToServer();
// JavaTransferService.buildModuleRestartShell(transferRequest, new TransferResult());
}
Also used : TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest) JavaTransferService(com.ibeiliao.deployment.transfer.service.JavaTransferService) Test(org.junit.Test)

Example 2 with TransferRequest

use of com.ibeiliao.deployment.transfer.vo.TransferRequest in project Corgi by kevinYin.

the class ViewProjectController method stopServer.

/**
 * 停止服务
 */
@RequestMapping("stopServer.do")
@ResponseBody
@MenuResource("停止服务")
public RestResult<Object> stopServer(int serverId) {
    TransferRequest request;
    try {
        request = createTransferRequest(serverId, false);
        Assert.isTrue(request.getModuleType() != ModuleType.STATIC.getValue(), "静态项目不能stop");
        JavaTransferService javaTransferService = new JavaTransferService(request, DeployType.STOP);
        return transfer(request.getHistoryId(), javaTransferService);
    } catch (Exception e) {
        logger.info("停止失败,{}", e);
        return new RestResult<>(ApiCode.FAILURE, "停止失败");
    }
}
Also used : TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest) JavaTransferService(com.ibeiliao.deployment.transfer.service.JavaTransferService) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with TransferRequest

use of com.ibeiliao.deployment.transfer.vo.TransferRequest 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)

Example 4 with TransferRequest

use of com.ibeiliao.deployment.transfer.vo.TransferRequest in project Corgi by kevinYin.

the class ViewProjectController method restartServer.

/**
 * 重启服务
 */
@RequestMapping("restartServer.do")
@ResponseBody
@MenuResource("重启服务")
public RestResult<Object> restartServer(int serverId) {
    TransferRequest request;
    try {
        request = createTransferRequest(serverId, true);
        Assert.isTrue(request.getModuleType() != ModuleType.STATIC.getValue(), "静态项目不能执行重启");
        JavaTransferService javaTransferService = new JavaTransferService(request, DeployType.RESTART);
        return transfer(request.getHistoryId(), javaTransferService);
    } catch (Exception e) {
        logger.info("重启失败, {}", e);
        return new RestResult<>(ApiCode.FAILURE, "重启失败");
    }
}
Also used : TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest) JavaTransferService(com.ibeiliao.deployment.transfer.service.JavaTransferService) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)4 JavaTransferService (com.ibeiliao.deployment.transfer.service.JavaTransferService)3 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1