提交 31ef7b68 编写于 作者: O o2null

Merge branch 'fix/代理超时时间改为可配置默认5分钟' into 'wrdp'

webserver代理超时时间改为可配置默认5分钟

See merge request o2oa/o2oa!4334
......@@ -42,6 +42,7 @@ public class WebServer extends ConfigObject {
private static final Boolean DEFAULT_PERSISTENTCONNECTIONSENABLE = true;
private static final Boolean DEFAULT_REQUESTLOGENABLE = false;
private static final String DEFAULT_REQUESTLOGFORMAT = "";
private static final Integer DEFAULT_PROXY_TIMEOUT = 300;
private static final Integer DEFAULT_REQUESTLOGRETAINDAYS = 7;
@FieldDescribe("是否启用")
......@@ -71,6 +72,9 @@ public class WebServer extends ConfigObject {
@FieldDescribe("是否启用application服务器代理")
private Boolean proxyApplicationEnable;
@FieldDescribe("代理连接超时时间,默认300(秒)")
private Integer proxyTimeOut;
@FieldDescribe("是否启用长连接,默认true.")
private Boolean persistentConnectionsEnable;
......@@ -193,9 +197,19 @@ public class WebServer extends ConfigObject {
return StringUtils.isEmpty(this.requestLogFormat) ? "" : this.requestLogFormat;
}
public Integer getProxyTimeOut() {
return proxyTimeOut == null ? DEFAULT_PROXY_TIMEOUT : this.proxyTimeOut;
}
public void setProxyTimeOut(Integer proxyTimeOut) {
this.proxyTimeOut = proxyTimeOut;
}
public Integer getRequestLogRetainDays() {
return (null == this.requestLogRetainDays || this.requestLogRetainDays < 1) ? DEFAULT_REQUESTLOGRETAINDAYS
: this.requestLogRetainDays;
}
}
......@@ -99,12 +99,12 @@ public class WebServerTools extends JettySeverTools {
server.setHandler(context);
if (BooleanUtils.isTrue(webServer.getProxyCenterEnable())) {
proxyCenter(context);
proxyCenter(context, webServer.getProxyTimeOut());
}
if (BooleanUtils.isTrue(webServer.getProxyApplicationEnable())) {
proxyApplication(context, Config.dir_store().toPath());
proxyApplication(context, Config.dir_custom().toPath());
proxyApplication(context, Config.dir_store().toPath(), webServer.getProxyTimeOut());
proxyApplication(context, Config.dir_custom().toPath(), webServer.getProxyTimeOut());
}
server.setDumpAfterStart(false);
......@@ -139,15 +139,15 @@ public class WebServerTools extends JettySeverTools {
StringUtils.isEmpty(webServer.getRequestLogFormat()) ? format : webServer.getRequestLogFormat());
}
private static void proxyCenter(WebAppContext context) throws Exception {
private static void proxyCenter(WebAppContext context, final Integer timeout) throws Exception {
ServletHolder proxyHolder = new ServletHolder(Proxy.class);
proxyHolder.setInitParameter("port", Config.currentNode().getCenter().getPort() + "");
proxyHolder.setInitParameter("idleTimeout", "60000");
proxyHolder.setInitParameter("timeout", "120000");
proxyHolder.setInitParameter("timeout", timeout + "000");
context.addServlet(proxyHolder, "/" + x_program_center.class.getSimpleName() + "/*");
}
private static void proxyApplication(WebAppContext context, Path path) throws Exception {
private static void proxyApplication(WebAppContext context, Path path, final Integer timeout) throws Exception {
try (Stream<Path> stream = Files.list(path)) {
stream.filter(o -> StringUtils.endsWithIgnoreCase(o.getFileName().toString(), ".war"))
.map(Path::getFileName).map(Path::toString).map(FilenameUtils::getBaseName)
......@@ -156,7 +156,7 @@ public class WebServerTools extends JettySeverTools {
ServletHolder proxyHolder = new ServletHolder(Proxy.class);
proxyHolder.setInitParameter("port", Config.currentNode().getApplication().getPort() + "");
proxyHolder.setInitParameter("idleTimeout", "60000");
proxyHolder.setInitParameter("timeout", "120000");
proxyHolder.setInitParameter("timeout", timeout + "000");
context.addServlet(proxyHolder, "/" + o + "/*");
} catch (Exception e) {
logger.error(e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册