mirror of https://github.com/prometheus/prometheus
Set read-timeout for http.Server
This also specifies a timeout for idle client connections, which may cause "too many open files" errors. See #2238pull/2240/head
parent
63fe65bf2f
commit
9986b28380
|
@ -80,6 +80,10 @@ func init() {
|
|||
&cfg.web.ListenAddress, "web.listen-address", ":9090",
|
||||
"Address to listen on for the web interface, API, and telemetry.",
|
||||
)
|
||||
cfg.fs.DurationVar(
|
||||
&cfg.web.ReadTimeout, "web.read-timeout", 30*time.Second,
|
||||
"Maximum duration before timing out read of the request, and closing idle connections.",
|
||||
)
|
||||
cfg.fs.StringVar(
|
||||
&cfg.prometheusURL, "web.external-url", "",
|
||||
"The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.",
|
||||
|
|
|
@ -111,6 +111,7 @@ type Options struct {
|
|||
Flags map[string]string
|
||||
|
||||
ListenAddress string
|
||||
ReadTimeout time.Duration
|
||||
ExternalURL *url.URL
|
||||
RoutePrefix string
|
||||
MetricsPath string
|
||||
|
@ -250,6 +251,7 @@ func (h *Handler) Run() {
|
|||
Addr: h.options.ListenAddress,
|
||||
Handler: h.router,
|
||||
ErrorLog: log.NewErrorLogger(),
|
||||
ReadTimeout: h.options.ReadTimeout,
|
||||
}
|
||||
h.listenErrCh <- server.ListenAndServe()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue