Skip to content

Commit

Permalink
fix data race
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvakhmistrov committed Dec 11, 2023
1 parent acd074c commit e5c1bc2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/command/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package command
import (
"context"
"net"
"net/http"
"time"

"github.com/gozix/di"
Expand All @@ -31,8 +32,13 @@ func NewHTTPServer(ctn di.Container) *cobra.Command {
logger.Info("Starting HTTP server", zap.String("addr", addr))

go func() {
if err = e.Start(addr); err != nil {
runErr := e.Start(addr)
if runErr == http.ErrServerClosed {
logger.Info("Gracefully shutting down the HTTP server")
return
}
if runErr != nil {
logger.Error("HTTP server terminated incorrectly", zap.Error(runErr))
}
}()

Expand Down

0 comments on commit e5c1bc2

Please sign in to comment.