Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2022-04-27 13:50:27 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-04-27 18:25:53 +0300
commit60e9cfb7e61fe9eb7141cc9e7d6e95495048bb37 (patch)
treee193f614f1b5454e7787b3d0acceb6e53a058bdd /server.go
parent46b4706ea917e4e5018c455d6737893d9426aada (diff)
Add support for socket listeners
Changelog: added
Diffstat (limited to 'server.go')
-rw-r--r--server.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/server.go b/server.go
index 9a647864..0c0c3c8d 100644
--- a/server.go
+++ b/server.go
@@ -7,6 +7,7 @@ import (
stdlog "log"
"net"
"net/http"
+ "path/filepath"
"github.com/pires/go-proxyproto"
"github.com/sirupsen/logrus"
@@ -47,7 +48,7 @@ func (a *theApp) listenAndServe(server *http.Server, addr string, h http.Handler
KeepAlive: a.config.Server.ListenKeepAlive,
}
- l, err := lc.Listen(context.Background(), "tcp", addr)
+ l, err := listenAddr(context.Background(), &lc, addr)
if err != nil {
return fmt.Errorf("failed to listen on addr %s: %w", addr, err)
}
@@ -77,6 +78,14 @@ func (a *theApp) listenAndServe(server *http.Server, addr string, h http.Handler
return server.Serve(l)
}
+func listenAddr(ctx context.Context, lc *net.ListenConfig, address string) (net.Listener, error) {
+ if filepath.IsAbs(address) {
+ return lc.Listen(ctx, "unix", address)
+ }
+
+ return lc.Listen(ctx, "tcp", address)
+}
+
type option func(*listenerConfig)
func withProxyV2() option {