Skip to content

Commit

Permalink
fix: crash on fail to listen
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Jan 5, 2021
1 parent 143c80b commit 39c4777
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,36 @@ func listen(handler http.Handler) {
if config.UseTLS() {
if s4 != nil {
fmt.Printf("Listening for HTTPS on %s.\n", s4.Addr)
go s4.ListenAndServeTLS(config.Server.TlsCertPath, config.Server.TlsKeyPath)
go func() {
if err := s4.ListenAndServeTLS(config.Server.TlsCertPath, config.Server.TlsKeyPath); err != nil {
log.Fatalln(err)
}
}()
}
if s6 != nil {
fmt.Printf("Listening for HTTPS on %s.\n", s6.Addr)
go s6.ListenAndServeTLS(config.Server.TlsCertPath, config.Server.TlsKeyPath)
go func() {
if err := s6.ListenAndServeTLS(config.Server.TlsCertPath, config.Server.TlsKeyPath); err != nil {
log.Fatalln(err)
}
}()
}
} else {
if s4 != nil {
fmt.Printf("Listening for HTTP on %s.\n", s4.Addr)
go s4.ListenAndServe()
go func() {
if err := s4.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}()
}
if s6 != nil {
fmt.Printf("Listening for HTTP on %s.\n", s6.Addr)
go s6.ListenAndServe()
go func() {
if err := s6.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}()
}
}

Expand Down

0 comments on commit 39c4777

Please sign in to comment.