|
|
@ -148,6 +148,9 @@ public class AjaxController {
|
|
|
|
baseResponse.addError(ErrorType.BUSINESS_ERROR, "程序尚未运行");
|
|
|
|
baseResponse.addError(ErrorType.BUSINESS_ERROR, "程序尚未运行");
|
|
|
|
return baseResponse;
|
|
|
|
return baseResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 刷新配置文件
|
|
|
|
|
|
|
|
flushConfig();
|
|
|
|
|
|
|
|
// 重新加载配置文件
|
|
|
|
ProcessUtil.execBat(nginxCtrl.getReloadCmd());
|
|
|
|
ProcessUtil.execBat(nginxCtrl.getReloadCmd());
|
|
|
|
return baseResponse;
|
|
|
|
return baseResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -210,10 +213,15 @@ public class AjaxController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void flushConfig() {
|
|
|
|
private void flushConfig() {
|
|
|
|
|
|
|
|
Writer wr = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
File config = nginxCtrl.getConfig();
|
|
|
|
HashMap<String, Object> context = new HashMap<>();
|
|
|
|
HashMap<String, Object> context = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PortLoadResponse portLoadResponse = (PortLoadResponse) loadPort("", LocalData.getSysToken());
|
|
|
|
|
|
|
|
context.put("services",portLoadResponse.getResult());
|
|
|
|
Template template = freeMarkerConfigurer.getConfiguration().getTemplate("nginx.conf");
|
|
|
|
Template template = freeMarkerConfigurer.getConfiguration().getTemplate("nginx.conf");
|
|
|
|
Writer wr = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8");
|
|
|
|
wr = new OutputStreamWriter(new FileOutputStream(config), "UTF-8");
|
|
|
|
//写入
|
|
|
|
//写入
|
|
|
|
template.process(context, wr);
|
|
|
|
template.process(context, wr);
|
|
|
|
//关闭流
|
|
|
|
//关闭流
|
|
|
@ -222,6 +230,12 @@ public class AjaxController {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (TemplateException e) {
|
|
|
|
} catch (TemplateException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
wr.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|