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());
}
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, "停止失败");
}
}
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("你没有权限操作,请联系项目负责人或超级管理员");
}
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, "重启失败");
}
}
Aggregations