summaryrefslogtreecommitdiff
path: root/workhorse/main.go
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-25 15:08:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-25 15:08:44 +0000
commit29516285ebf20d2c9836d5263f9d3fba21d04a95 (patch)
treecb88f9184fd4bd12e97a3207eaa9d774014d7679 /workhorse/main.go
parent52eb17ad859d778104993ee0edfa9c034e59af80 (diff)
downloadgitlab-ce-29516285ebf20d2c9836d5263f9d3fba21d04a95.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'workhorse/main.go')
-rw-r--r--workhorse/main.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/workhorse/main.go b/workhorse/main.go
index 123d21596e2..a2156b491e7 100644
--- a/workhorse/main.go
+++ b/workhorse/main.go
@@ -22,6 +22,7 @@ import (
"gitlab.com/gitlab-org/gitlab/workhorse/internal/queueing"
"gitlab.com/gitlab-org/gitlab/workhorse/internal/redis"
"gitlab.com/gitlab-org/gitlab/workhorse/internal/secret"
+ "gitlab.com/gitlab-org/gitlab/workhorse/internal/server"
"gitlab.com/gitlab-org/gitlab/workhorse/internal/upstream"
)
@@ -155,6 +156,7 @@ func buildConfig(arg0 string, args []string) (*bootConfig, *config.Config, error
cfg.ShutdownTimeout = cfgFromFile.ShutdownTimeout
cfg.TrustedCIDRsForXForwardedFor = cfgFromFile.TrustedCIDRsForXForwardedFor
cfg.TrustedCIDRsForPropagation = cfgFromFile.TrustedCIDRsForPropagation
+ cfg.Listeners = cfgFromFile.Listeners
return boot, cfg, nil
}
@@ -177,14 +179,6 @@ func run(boot bootConfig, cfg config.Config) error {
}
}
- // Change the umask only around net.Listen()
- oldUmask := syscall.Umask(boot.listenUmask)
- listener, err := net.Listen(boot.listenNetwork, boot.listenAddr)
- syscall.Umask(oldUmask)
- if err != nil {
- return fmt.Errorf("main listener: %v", err)
- }
-
finalErrors := make(chan error)
// The profiler will only be activated by HTTP requests. HTTP
@@ -241,8 +235,19 @@ func run(boot bootConfig, cfg config.Config) error {
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
- server := http.Server{Handler: up}
- go func() { finalErrors <- server.Serve(listener) }()
+ listenerFromBootConfig := config.ListenerConfig{
+ Network: boot.listenNetwork,
+ Addr: boot.listenAddr,
+ }
+ srv := &server.Server{
+ Handler: up,
+ Umask: boot.listenUmask,
+ ListenerConfigs: append(cfg.Listeners, listenerFromBootConfig),
+ Errors: finalErrors,
+ }
+ if err := srv.Run(); err != nil {
+ return fmt.Errorf("running server: %v", err)
+ }
select {
case err := <-finalErrors:
@@ -254,6 +259,6 @@ func run(boot bootConfig, cfg config.Config) error {
defer cancel()
redis.Shutdown()
- return server.Shutdown(ctx)
+ return srv.Shutdown(ctx)
}
}