Handling correctly closing the server

This commit is contained in:
ErickSkrauch 2020-04-20 15:34:52 +03:00
parent cc4cd2874c
commit 0be85b356b
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E

View File

@ -23,10 +23,11 @@ func StartServer(server *http.Server, logger slf.Logger) {
done := make(chan bool, 1)
go func() {
logger.Info("Starting the server, HTTP on: :addr", wd.StringParam("addr", server.Addr))
if err := server.ListenAndServe(); err != nil {
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logger.Emergency("Error in main(): :err", wd.ErrParam(err))
close(done)
}
close(done)
}()
go func() {