Skip to content

Commit 1495793

Browse files
committed
expose keep-alive timeout on command-line
1 parent ebeb1ea commit 1495793

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bin/configurable-http-proxy

+7
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ cli
103103
.option(
104104
"--storage-backend <storage-class>",
105105
"Define an external storage class. Defaults to in-MemoryStore."
106+
)
107+
.option(
108+
"--keep-alive-timeout <timeout>",
109+
"Set timeout (in milliseconds) for Keep-Alive connections",
110+
5000
106111
);
107112

108113
// collects multiple flags to an object
@@ -269,6 +274,8 @@ options.redirectTo = args.redirectTo;
269274
options.headers = args.customHeader;
270275
options.timeout = args.timeout;
271276
options.proxyTimeout = args.proxyTimeout;
277+
// cast to milliseconds, which is what
278+
options.keepAliveTimeout = args.keepAliveTimeout;
272279

273280
// metrics options
274281
options.enableMetrics = !!args.metricsPort;

lib/configproxy.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ class ConfigurableProxy extends EventEmitter {
220220
this.metricsServer = http.createServer(metricsCallback);
221221
}
222222

223-
var httpOptions = { keepAlive: true, agent: this.agent };
223+
var httpOptions = {
224+
keepAlive: true,
225+
agent: this.agent,
226+
keepAliveTimeout: this.options.keepAliveTimeout || 5000,
227+
};
224228

225229
// proxy requests separately
226230
var proxyCallback = logErrors(this.handleProxyWeb);

0 commit comments

Comments
 (0)