...
|
...
|
@@ -100,8 +100,15 @@ public class GrayNginxSwitchCtrl { |
|
|
public BaseResponse viewGrayNginxToChangeConf(String onlineOrGray) {
|
|
|
String nginxConfContent=exe(" -eview -n"+grayNginxAddress);
|
|
|
|
|
|
String service_replace_upstream1="grayapigateway";
|
|
|
|
|
|
nginxConfContent = replaceConf(nginxConfContent,onlineOrGray," grayapigateway");
|
|
|
//" apigateway"一定要有一个空格在前面
|
|
|
nginxConfContent = replaceConf(nginxConfContent,onlineOrGray," apigateway");
|
|
|
|
|
|
return new BaseResponse(200, "SUCCESS",nginxConfContent);
|
|
|
}
|
|
|
|
|
|
private String replaceConf(String nginxConfContent,String onlineOrGray,String key_flag_replace_upstream){
|
|
|
StringBuilder sbConfToChange = new StringBuilder();
|
|
|
boolean replaceFlag=false;
|
|
|
Scanner scn = new Scanner(nginxConfContent);
|
...
|
...
|
@@ -143,14 +150,13 @@ public class GrayNginxSwitchCtrl { |
|
|
}
|
|
|
|
|
|
//替换开始标志
|
|
|
if(lineContent_trim.startsWith("upstream")&&lineContent_trim.indexOf(service_replace_upstream1)>0){
|
|
|
if(lineContent_trim.startsWith("upstream")&&lineContent_trim.indexOf(key_flag_replace_upstream)>0){
|
|
|
replaceFlag=true;
|
|
|
}
|
|
|
|
|
|
sbConfToChange.append(lineContent + "\r\n");
|
|
|
}
|
|
|
|
|
|
return new BaseResponse(200, "SUCCESS",sbConfToChange.toString());
|
|
|
return sbConfToChange.toString();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -199,8 +205,8 @@ public class GrayNginxSwitchCtrl { |
|
|
}
|
|
|
|
|
|
|
|
|
/* public static void main(String args[]){
|
|
|
String path="C:\\Users\\craig.qin\\Desktop\\tmp\\nginx.conf";
|
|
|
/* public static void main(String args[]){
|
|
|
String path="D:\\temp\\nconf.conf";
|
|
|
|
|
|
BufferedReader bufferedReader = null;
|
|
|
StringBuilder sb = new StringBuilder();
|
...
|
...
|
@@ -223,10 +229,22 @@ public class GrayNginxSwitchCtrl { |
|
|
System.out.println(sb.toString());
|
|
|
|
|
|
System.out.println("------------->");
|
|
|
GrayNginxSwitchCtrl c=new GrayNginxSwitchCtrl();
|
|
|
|
|
|
|
|
|
System.out.println(c.test(sb.toString(),"gray").getData());
|
|
|
|
|
|
}
|
|
|
|
|
|
public BaseResponse test(String nginxConfContent,String onlineOrGray) {
|
|
|
|
|
|
|
|
|
// System.out.println(test(sb.toString(),"gray"));
|
|
|
nginxConfContent = replaceConf(nginxConfContent,onlineOrGray," grayapigateway");
|
|
|
//" apigateway"一定要有一个空格在前面
|
|
|
nginxConfContent = replaceConf(nginxConfContent,onlineOrGray," apigateway");
|
|
|
|
|
|
}*/
|
|
|
return new BaseResponse(200, "SUCCESS",nginxConfContent);
|
|
|
}*/
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|