diff options
-rw-r--r-- | app.go | 3 | ||||
-rw-r--r-- | internal/config/config.go | 20 | ||||
-rw-r--r-- | internal/config/flags.go | 1 |
3 files changed, 13 insertions, 11 deletions
@@ -378,8 +378,7 @@ func (a *theApp) Run() { var result *multierror.Error for _, srv := range servers { - // TODO: make this timeout configurable - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), a.config.General.ServerShutdownTimeout) if err := srv.Shutdown(ctx); err != nil { result = multierror.Append(result, err) diff --git a/internal/config/config.go b/internal/config/config.go index 24a811ec..cef23be8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -35,15 +35,16 @@ type Config struct { // General groups settings that are general to GitLab Pages and can not // be categorized under other head. type General struct { - Domain string - MaxConns int - MaxURILength int - MetricsAddress string - RedirectHTTP bool - RootCertificate []byte - RootDir string - RootKey []byte - StatusPath string + Domain string + MaxConns int + MaxURILength int + MetricsAddress string + RedirectHTTP bool + RootCertificate []byte + RootDir string + RootKey []byte + ServerShutdownTimeout time.Duration + StatusPath string DisableCrossOriginRequests bool InsecureCiphers bool @@ -177,6 +178,7 @@ func loadConfig() (*Config, error) { RedirectHTTP: *redirectHTTP, RootDir: *pagesRoot, StatusPath: *pagesStatus, + ServerShutdownTimeout: *serverShutdownTimeout, DisableCrossOriginRequests: *disableCrossOriginRequests, InsecureCiphers: *insecureCiphers, PropagateCorrelationID: *propagateCorrelationID, diff --git a/internal/config/flags.go b/internal/config/flags.go index 409ecdc7..5ddc7df6 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -47,6 +47,7 @@ var ( _ = flag.Bool("daemon-enable-jail", false, "DEPRECATED and ignored, will be removed in 15.0") _ = flag.Bool("daemon-inplace-chroot", false, "DEPRECATED and ignored, will be removed in 15.0") // TODO: https://gitlab.com/gitlab-org/gitlab-pages/-/issues/599 propagateCorrelationID = flag.Bool("propagate-correlation-id", false, "Reuse existing Correlation-ID from the incoming request header `X-Request-ID` if present") + serverShutdownTimeout = flag.Duration("server-shutdown-timeout", 30*time.Second, "GitLab Pages server shutdown timeout (default: 30s)") logFormat = flag.String("log-format", "json", "The log output format: 'text' or 'json'") logVerbose = flag.Bool("log-verbose", false, "Verbose logging") secret = flag.String("auth-secret", "", "Cookie store hash key, should be at least 32 bytes long") |