Don't require systemd sockets in dev mode
Because otherwise I can't run the program on my dev server
This commit is contained in:
parent
5ac778ea53
commit
822dad5352
1 changed files with 21 additions and 11 deletions
32
main.go
32
main.go
|
|
@ -146,22 +146,32 @@ func main() {
|
||||||
log.Error().Err(err).Msg("Failed to start openAI client")
|
log.Error().Err(err).Msg("Failed to start openAI client")
|
||||||
os.Exit(8)
|
os.Exit(8)
|
||||||
}
|
}
|
||||||
listeners, _ := activation.Listeners()
|
|
||||||
if len(listeners) != 1 {
|
|
||||||
log.Error().Int("len", len(listeners)).Msg("Unexpected number of socket activation FDs")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: config.Bind,
|
Addr: config.Bind,
|
||||||
Handler: r,
|
Handler: r,
|
||||||
}
|
}
|
||||||
go func() {
|
if config.IsProductionEnvironment() {
|
||||||
log.Info().Str("address", config.Bind).Msg("Serving HTTP requests")
|
listeners, _ := activation.Listeners()
|
||||||
if err := server.Serve(listeners[0]); err != nil && err != http.ErrServerClosed {
|
if len(listeners) != 1 {
|
||||||
log.Error().Str("err", err.Error()).Msg("HTTP Server Error")
|
log.Error().Int("len", len(listeners)).Msg("Unexpected number of socket activation FDs")
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
log.Debug().Msg("Exiting listen-and-serve goroutine")
|
go func() {
|
||||||
}()
|
log.Info().Str("address", config.Bind).Msg("Serving HTTP requests")
|
||||||
|
if err := server.Serve(listeners[0]); err != nil && err != http.ErrServerClosed {
|
||||||
|
log.Error().Str("err", err.Error()).Msg("HTTP Server Error")
|
||||||
|
}
|
||||||
|
log.Debug().Msg("Exiting listen-and-serve goroutine")
|
||||||
|
}()
|
||||||
|
} else {
|
||||||
|
go func() {
|
||||||
|
log.Info().Str("address", config.Bind).Msg("Serving HTTP requests")
|
||||||
|
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
|
log.Error().Str("err", err.Error()).Msg("HTTP Server Error")
|
||||||
|
}
|
||||||
|
log.Debug().Msg("Exiting listen-and-serve goroutine")
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
chan_envelope := make(chan platform.Envelope, 10)
|
chan_envelope := make(chan platform.Envelope, 10)
|
||||||
platform.SetEventChannel(chan_envelope)
|
platform.SetEventChannel(chan_envelope)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue