Skip to content

Commit 4e760e8

Browse files
committed
feat: add option to enable or disable concurrent listeners
1 parent 02b48aa commit 4e760e8

2 files changed

Lines changed: 43 additions & 20 deletions

File tree

internal/bootstrap/app_bootstrap.go

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,42 @@ func (app *BootstrapApp) Setup() error {
238238
}
239239

240240
// create err channel to listen for server errors
241-
errChan := make(chan error, 2)
241+
errChanLen := 0
242+
243+
runUnix := app.config.Server.SocketPath != ""
244+
runHTTP := app.config.Server.SocketPath == "" || app.config.Server.ConcurrentListenersEnabled
245+
246+
if runUnix {
247+
errChanLen++
248+
}
249+
250+
if runHTTP {
251+
errChanLen++
252+
}
253+
254+
errChan := make(chan error, errChanLen)
255+
256+
if app.config.Server.ConcurrentListenersEnabled {
257+
app.log.App.Info().Msg("Concurrent listeners enabled, will run on all available listeners")
258+
}
242259

243260
// serve unix
244-
app.wg.Go(func() {
245-
if err := app.serveUnix(); err != nil {
246-
errChan <- err
247-
}
248-
})
261+
if runUnix {
262+
app.wg.Go(func() {
263+
if err := app.serveUnix(); err != nil {
264+
errChan <- err
265+
}
266+
})
267+
}
249268

250269
// serve to http
251-
app.wg.Go(func() {
252-
if err := app.serveHTTP(); err != nil {
253-
errChan <- err
254-
}
255-
})
270+
if runHTTP {
271+
app.wg.Go(func() {
272+
if err := app.serveHTTP(); err != nil {
273+
errChan <- err
274+
}
275+
})
276+
}
256277

257278
// monitor cancellation and server errors
258279
for {

internal/model/config.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ func NewDefaultConfiguration() *Config {
1414
Path: "./resources",
1515
},
1616
Server: ServerConfig{
17-
Port: 3000,
18-
Address: "0.0.0.0",
17+
Port: 3000,
18+
Address: "0.0.0.0",
19+
ConcurrentListenersEnabled: false,
1920
},
2021
Auth: AuthConfig{
2122
SubdomainsEnabled: true,
@@ -95,9 +96,10 @@ type ResourcesConfig struct {
9596
}
9697

9798
type ServerConfig struct {
98-
Port int `description:"The port on which the server listens." yaml:"port"`
99-
Address string `description:"The address on which the server listens." yaml:"address"`
100-
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"`
99+
Port int `description:"The port on which the server listens." yaml:"port"`
100+
Address string `description:"The address on which the server listens." yaml:"address"`
101+
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"`
102+
ConcurrentListenersEnabled bool `description:"Enable listening on both TCP and Unix socket at the same time." yaml:"concurrentListenersEnabled"`
101103
}
102104

103105
type AuthConfig struct {
@@ -147,10 +149,10 @@ type IPConfig struct {
147149
}
148150

149151
type OAuthConfig struct {
150-
Whitelist []string `description:"Comma-separated list of allowed OAuth domains." yaml:"whitelist"`
151-
WhitelistFile string `description:"Path to the OAuth whitelist file." yaml:"whitelistFile"`
152-
AutoRedirect string `description:"The OAuth provider to use for automatic redirection." yaml:"autoRedirect"`
153-
Providers map[string]OAuthServiceConfig `description:"OAuth providers configuration." yaml:"providers"`
152+
Whitelist []string `description:"Comma-separated list of allowed OAuth domains." yaml:"whitelist"`
153+
WhitelistFile string `description:"Path to the OAuth whitelist file." yaml:"whitelistFile"`
154+
AutoRedirect string `description:"The OAuth provider to use for automatic redirection." yaml:"autoRedirect"`
155+
Providers map[string]OAuthServiceConfig `description:"OAuth providers configuration." yaml:"providers"`
154156
}
155157

156158
type OIDCConfig struct {

0 commit comments

Comments
 (0)