Authored by qinchao

nginx自动伸缩

... ... @@ -240,6 +240,15 @@ public class CloudToolController {
return new BaseResponse();
}
/**
* memcache伸缩后,更新监控对象
* @return
*/
@RequestMapping("/updateNginxConfig")
@ResponseBody
public BaseResponse updateNginxConfig(@RequestBody AutoScalingInfoReq infoReq){
return cloudToolService.updateNginxConfig(infoReq);
}
}
\ No newline at end of file
... ...
... ... @@ -20,4 +20,7 @@ public class AutoScalingInfoReq {
//java或者PC/H5
private String memcacheType;
//nginx类型:java 或者pch5
private String nginxType;
}
... ...
... ... @@ -33,4 +33,6 @@ public interface CloudToolService {
void updateMemcacheInfoForInternalDomain(AutoScalingInfoReq infoReq);
void updateMemcacheInfoForMobject(AutoScalingInfoReq infoReq);
BaseResponse updateNginxConfig(AutoScalingInfoReq infoReq);
}
\ No newline at end of file
... ...
... ... @@ -350,6 +350,47 @@ public class CloudToolServiceImpl implements CloudToolService {
}
}
public BaseResponse updateNginxConfig(AutoScalingInfoReq infoReq){
BaseResponse response=new BaseResponse();
StringBuilder commond = new StringBuilder();
commond.append("sh /home/master/ops-sh/");
if("java".equalsIgnoreCase(infoReq.getNginxType())){
commond.append("java-nginx.sh ");
}else{
commond.append("pch5-nginx.sh ");////要有空格
}
String cloud = "aws";
if(2==infoReq.getCloudType()){
cloud="qcloud";
}
commond.append("\""+cloud+"\"");
String ips=infoReq.getNewInstanceIps();
commond.append(" ");
String allips="";
for(String ip:ips.split(",")){
if(allips.length()>0){
allips += " ";
}
allips += ip;
}
commond.append("\"");
commond.append(allips);
commond.append("\"");
logger.error(" - begin - updateNginxConfig- sql"+commond.toString());
response.setMessage(commond.toString());
try{
CommodUtil.exe(commond.toString());
}catch (Exception e){
logger.error(" - CloudToolServiceImpl - updateNginxConfig- error", e);
response.setCode(300);
response.setMessage(e.getMessage());
}
return response;
}
public String buildMoName(String prename,String environment) {
if(environment.equals("aws")){
prename += "_aws_";
... ...