1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: crash on fail to listen

This commit is contained in:
Ferdinand Mütsch 2021-01-05 11:28:51 +01:00
parent 143c80b7b4
commit 39c4777fc8

24
main.go
View File

@ -210,20 +210,36 @@ func listen(handler http.Handler) {
if config.UseTLS() { if config.UseTLS() {
if s4 != nil { if s4 != nil {
fmt.Printf("Listening for HTTPS on %s.\n", s4.Addr) 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 { if s6 != nil {
fmt.Printf("Listening for HTTPS on %s.\n", s6.Addr) 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 { } else {
if s4 != nil { if s4 != nil {
fmt.Printf("Listening for HTTP on %s.\n", s4.Addr) 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 { if s6 != nil {
fmt.Printf("Listening for HTTP on %s.\n", s6.Addr) fmt.Printf("Listening for HTTP on %s.\n", s6.Addr)
go s6.ListenAndServe() go func() {
if err := s6.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}()
} }
} }