use of com.ibeiliao.deployment.transfer.vo.ResinConf in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method loadModuleConf.
/**
* 加载模块配置,比如 web 配置
*
* @param projectModule
* @author linyi 2017/3/14
*/
private void loadModuleConf(ProjectModule projectModule) {
ModuleConfPO moduleConf = moduleConfDao.get(Constants.CONF_TYPE_RESIN, projectModule.getModuleId());
if (moduleConf != null && StringUtils.isNotEmpty(moduleConf.getConfValue())) {
ResinConf resinConf = JSON.parseObject(moduleConf.getConfValue(), ResinConf.class);
resinConf.setModuleId(projectModule.getModuleId());
projectModule.setResinConf(resinConf);
}
}
use of com.ibeiliao.deployment.transfer.vo.ResinConf in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method saveResinConf.
/**
* 保存 resin 配置
*
* @param projectModule
* @author linyi 2017/3/14
*/
private void saveResinConf(ProjectModule projectModule) {
if (projectModule.getModuleType() == ModuleType.WEB_PROJECT.getValue()) {
ResinConf resinConf = projectModule.getResinConf();
resinConf.setConfType(Constants.CONF_TYPE_RESIN);
resinConf.setModuleId(projectModule.getModuleId());
ModuleConfPO current = moduleConfDao.get(resinConf.getConfType(), projectModule.getModuleId());
if (resinConf.getKeepaliveTimeout() <= 0) {
resinConf.setKeepaliveTimeout(Constants.DEFAULT_KEEPALIVE_TIMEOUT);
}
if (resinConf.getSocketTimeout() <= 0) {
resinConf.setSocketTimeout(Constants.DEFAULT_SOCKET_TIMEOUT);
}
if (current == null) {
ModuleConfPO po = new ModuleConfPO();
po.setConfType(resinConf.getConfType());
po.setModuleId(projectModule.getModuleId());
po.setCreateTime(new Date());
po.setUpdateTime(po.getCreateTime());
po.setConfValue(JSON.toJSONString(resinConf));
moduleConfDao.insert(po);
} else {
current.setUpdateTime(new Date());
current.setConfValue(JSON.toJSONString(resinConf));
moduleConfDao.update(current);
}
}
}
use of com.ibeiliao.deployment.transfer.vo.ResinConf in project Corgi by kevinYin.
the class ResinConfTemplateTest method testCreateConf.
@Test
public void testCreateConf() throws Exception {
ResinConf resinConf = new ResinConf();
resinConf.setDomain("pf.dev.ibeiliao.net");
resinConf.setSocketTimeout(30);
resinConf.setKeepaliveTimeout(15);
resinConf.setHttpPort(8080);
resinConf.setServerPort(6800);
resinConf.setWatchdogPort(6600);
ModuleConf moduleConf = new ModuleConf();
moduleConf.setProjectNo("platform-parent");
moduleConf.setShortModuleName("platform-admin");
moduleConf.setModuleFinalName("platform-admin.war");
moduleConf.setJvmArg("-Xms128m -Xmx160m -d64 -server");
ResinConfTemplate template = new ResinConfTemplate(resinConf, moduleConf);
template.createConfFiles("d://temp//resin");
}
use of com.ibeiliao.deployment.transfer.vo.ResinConf 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.ResinConf in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method validateModule.
private void validateModule(ProjectModule projectModule) {
Assert.notNull(projectModule, "参数不能为null");
Assert.isTrue(StringUtils.isNotBlank(projectModule.getModuleNameZh()), "模块名称不能为空");
Assert.isTrue(StringUtils.isNotBlank(projectModule.getModuleName()), "模块名称不能为空");
if (projectModule.getModuleType() != ModuleType.STATIC.getValue()) {
Assert.hasText(projectModule.getRestartShell(), "请输入restart shell");
}
Assert.hasText(projectModule.getCompileShell(), "请输入编译脚本");
validateJvmArgs(projectModule);
if (projectModule.getModuleType() == ModuleType.WEB_PROJECT.getValue()) {
Assert.notNull(projectModule.getResinConf(), "Resin配置不能为null");
ResinConf resinConf = projectModule.getResinConf();
Assert.isTrue(resinConf.getHttpPort() > 0, "http端口错误");
Assert.isTrue(resinConf.getServerPort() > 0, "server端口错误");
Assert.isTrue(resinConf.getWatchdogPort() > 0, "watchdog端口错误");
// Assert.hasText(resinConf.getDomain(), "域名配置错误");
String domain = resinConf.getDomain().trim().toLowerCase();
if (domain.startsWith("http://")) {
domain = domain.substring("http://".length());
} else if (domain.startsWith("https://")) {
domain = domain.substring("https://".length());
}
if (StringUtils.isNotBlank(domain)) {
Assert.isTrue(isLegalDomain(domain), "域名格式错误: " + domain);
resinConf.setDomain(domain);
} else {
resinConf.setDomain("");
}
}
}
Aggregations