mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-05-10 22:38:10 +00:00
feat: add option to enable or disable concurrent listeners
This commit is contained in:
@@ -238,21 +238,42 @@ func (app *BootstrapApp) Setup() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create err channel to listen for server errors
|
// 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
|
// serve unix
|
||||||
|
if runUnix {
|
||||||
app.wg.Go(func() {
|
app.wg.Go(func() {
|
||||||
if err := app.serveUnix(); err != nil {
|
if err := app.serveUnix(); err != nil {
|
||||||
errChan <- err
|
errChan <- err
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// serve to http
|
// serve to http
|
||||||
|
if runHTTP {
|
||||||
app.wg.Go(func() {
|
app.wg.Go(func() {
|
||||||
if err := app.serveHTTP(); err != nil {
|
if err := app.serveHTTP(); err != nil {
|
||||||
errChan <- err
|
errChan <- err
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// monitor cancellation and server errors
|
// monitor cancellation and server errors
|
||||||
for {
|
for {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ func NewDefaultConfiguration() *Config {
|
|||||||
Server: ServerConfig{
|
Server: ServerConfig{
|
||||||
Port: 3000,
|
Port: 3000,
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
|
ConcurrentListenersEnabled: false,
|
||||||
},
|
},
|
||||||
Auth: AuthConfig{
|
Auth: AuthConfig{
|
||||||
SubdomainsEnabled: true,
|
SubdomainsEnabled: true,
|
||||||
@@ -98,6 +99,7 @@ type ServerConfig struct {
|
|||||||
Port int `description:"The port on which the server listens." yaml:"port"`
|
Port int `description:"The port on which the server listens." yaml:"port"`
|
||||||
Address string `description:"The address on which the server listens." yaml:"address"`
|
Address string `description:"The address on which the server listens." yaml:"address"`
|
||||||
SocketPath string `description:"The path to the Unix socket." yaml:"socketPath"`
|
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 {
|
type AuthConfig struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user