diff options
author | Max Wittig <max.wittig95@gmail.com> | 2019-07-10 20:09:18 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-07-10 20:09:18 +0300 |
commit | 45581f8cb7c40029c90957707fa5d7663f9b01ba (patch) | |
tree | 308b5637f302e1af1acbd06c10187b392f246801 /app.go | |
parent | bd8aff8fd5cfe26ac576d351043239ffd309f8be (diff) |
Revert "chore: vendor complete dependency tree"
This reverts commit 27bd4d83cade6a721330e8583874e7c715bf3a26.
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -2,6 +2,7 @@ package main import ( "crypto/tls" + "errors" "fmt" "net" "net/http" @@ -15,6 +16,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/cors" log "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/labkit/errortracking" mimedb "gitlab.com/lupine/go-mimedb" "gitlab.com/gitlab-org/gitlab-pages/internal/acme" @@ -37,6 +39,11 @@ var ( corsHandler = cors.New(cors.Options{AllowedMethods: []string{"GET"}}) ) +var ( + errStartListener = errors.New("Could not start listener") + errX509KeyPair = errors.New("Could not initialize KeyPair") +) + type theApp struct { appConfig dm domain.Map @@ -254,7 +261,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServe(fd, a.ServeHTTP, a.HTTP2, nil, limiter) if err != nil { - fatal(err) + capturingFatal(err, errortracking.WithField("listener", "http")) } }(fd) } @@ -266,7 +273,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServeTLS(fd, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.InsecureCiphers, a.TLSMinVersion, a.TLSMaxVersion, a.HTTP2, limiter) if err != nil { - fatal(err) + capturingFatal(err, errortracking.WithField("listener", "https")) } }(fd) } @@ -278,7 +285,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServe(fd, a.ServeProxy, a.HTTP2, nil, limiter) if err != nil { - fatal(err) + capturingFatal(err, errortracking.WithField("listener", "http proxy")) } }(fd) } @@ -292,7 +299,7 @@ func (a *theApp) Run() { handler := promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).ServeHTTP err := listenAndServe(fd, handler, false, nil, nil) if err != nil { - fatal(err) + capturingFatal(err, errortracking.WithField("listener", "metrics")) } }(a.ListenMetrics) } @@ -317,6 +324,7 @@ func (a *theApp) listenAdminUnix(wg *sync.WaitGroup) { l, err := net.FileListener(os.NewFile(fd, "[admin-socket-unix]")) if err != nil { + errortracking.Capture(err, errortracking.WithField("listener", "admin unix socket")) fatal(fmt.Errorf("failed to listen on FD %d: %v", fd, err)) } defer l.Close() @@ -335,7 +343,7 @@ func (a *theApp) listenAdminHTTPS(wg *sync.WaitGroup) { cert, err := tls.X509KeyPair(a.AdminCertificate, a.AdminKey) if err != nil { - fatal(err) + capturingFatal(err) } wg.Add(1) @@ -344,7 +352,9 @@ func (a *theApp) listenAdminHTTPS(wg *sync.WaitGroup) { l, err := net.FileListener(os.NewFile(fd, "[admin-socket-https]")) if err != nil { - fatal(fmt.Errorf("failed to listen on FD %d: %v", fd, err)) + errMsg := fmt.Sprintf("failed to listen on FD %d: %v", fd, err) + log.Error(errMsg) + capturingFatal(err, errortracking.WithField("listener", "admin https socket")) } defer l.Close() |