diff --git a/internal/bootstrap/app_bootstrap.go b/internal/bootstrap/app_bootstrap.go index 36afb79a..7d983ff7 100644 --- a/internal/bootstrap/app_bootstrap.go +++ b/internal/bootstrap/app_bootstrap.go @@ -238,21 +238,42 @@ func (app *BootstrapApp) Setup() error { } // create err channel to listen for server errors - errChan := make(chan error, 2) + errChanLen := 0 + + runUnix := app.config.Server.SocketPath != "" + runHTTP := app.config.Server.SocketPath == "" || app.config.Server.ConcurrentListenersEnabled + + if runUnix { + errChanLen++ + } + + if runHTTP { + errChanLen++ + } + + errChan := make(chan error, errChanLen) + + if app.config.Server.ConcurrentListenersEnabled { + app.log.App.Info().Msg("Concurrent listeners enabled, will run on all available listeners") + } // serve unix - app.wg.Go(func() { - if err := app.serveUnix(); err != nil { - errChan <- err - } - }) + if runUnix { + app.wg.Go(func() { + if err := app.serveUnix(); err != nil { + errChan <- err + } + }) + } // serve to http - app.wg.Go(func() { - if err := app.serveHTTP(); err != nil { - errChan <- err - } - }) + if runHTTP { + app.wg.Go(func() { + if err := app.serveHTTP(); err != nil { + errChan <- err + } + }) + } // monitor cancellation and server errors for { diff --git a/internal/model/config.go b/internal/model/config.go index 95870e3d..f5376af2 100644 --- a/internal/model/config.go +++ b/internal/model/config.go @@ -14,8 +14,9 @@ func NewDefaultConfiguration() *Config { Path: "./resources", }, Server: ServerConfig{ - Port: 3000, - Address: "0.0.0.0", + Port: 3000, + Address: "0.0.0.0", + ConcurrentListenersEnabled: false, }, Auth: AuthConfig{ SubdomainsEnabled: true, @@ -95,9 +96,10 @@ type ResourcesConfig struct { } type ServerConfig struct { - Port int `description:"The port on which the server listens." yaml:"port"` - Address string `description:"The address on which the server listens." yaml:"address"` - SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"` + Port int `description:"The port on which the server listens." yaml:"port"` + Address string `description:"The address on which the server listens." yaml:"address"` + SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"` + ConcurrentListenersEnabled bool `description:"Enable listening on both TCP and Unix socket at the same time." yaml:"concurrentListenersEnabled"` } type AuthConfig struct { @@ -147,10 +149,10 @@ type IPConfig struct { } type OAuthConfig struct { - Whitelist []string `description:"Comma-separated list of allowed OAuth domains." yaml:"whitelist"` - WhitelistFile string `description:"Path to the OAuth whitelist file." yaml:"whitelistFile"` - AutoRedirect string `description:"The OAuth provider to use for automatic redirection." yaml:"autoRedirect"` - Providers map[string]OAuthServiceConfig `description:"OAuth providers configuration." yaml:"providers"` + Whitelist []string `description:"Comma-separated list of allowed OAuth domains." yaml:"whitelist"` + WhitelistFile string `description:"Path to the OAuth whitelist file." yaml:"whitelistFile"` + AutoRedirect string `description:"The OAuth provider to use for automatic redirection." yaml:"autoRedirect"` + Providers map[string]OAuthServiceConfig `description:"OAuth providers configuration." yaml:"providers"` } type OIDCConfig struct {