diff options
author | Nick Thomas <nick@gitlab.com> | 2018-10-24 05:11:29 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-10-26 23:09:50 +0300 |
commit | 513a357961b1693c1d3f8450430d72b2d1d354be (patch) | |
tree | bc186e85fecb069f08681dcc48d683c9514306f1 /app.go | |
parent | 49cc251dafd31762dd9eca096a9eba963c469a26 (diff) |
Allow the maximum connection concurrency to be specified
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -22,6 +22,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/auth" "gitlab.com/gitlab-org/gitlab-pages/internal/domain" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" + "gitlab.com/gitlab-org/gitlab-pages/internal/netutil" "gitlab.com/gitlab-org/gitlab-pages/metrics" ) @@ -243,12 +244,14 @@ func (a *theApp) UpdateDomains(dm domain.Map) { func (a *theApp) Run() { var wg sync.WaitGroup + limiter := netutil.NewLimiter(a.MaxConns) + // Listen for HTTP for _, fd := range a.ListenHTTP { wg.Add(1) go func(fd uintptr) { defer wg.Done() - err := listenAndServe(fd, a.ServeHTTP, a.HTTP2, nil) + err := listenAndServe(fd, a.ServeHTTP, a.HTTP2, nil, limiter) if err != nil { fatal(err) } @@ -260,7 +263,7 @@ func (a *theApp) Run() { wg.Add(1) go func(fd uintptr) { defer wg.Done() - err := listenAndServeTLS(fd, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.HTTP2) + err := listenAndServeTLS(fd, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.HTTP2, limiter) if err != nil { fatal(err) } @@ -272,7 +275,7 @@ func (a *theApp) Run() { wg.Add(1) go func(fd uintptr) { defer wg.Done() - err := listenAndServe(fd, a.ServeProxy, a.HTTP2, nil) + err := listenAndServe(fd, a.ServeProxy, a.HTTP2, nil, limiter) if err != nil { fatal(err) } @@ -286,7 +289,7 @@ func (a *theApp) Run() { defer wg.Done() handler := promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).ServeHTTP - err := listenAndServe(fd, handler, false, nil) + err := listenAndServe(fd, handler, false, nil, nil) if err != nil { fatal(err) } |