File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package server
33import (
44 "context"
55 "crypto/tls"
6+ "errors"
67 "fmt"
78 "log/slog"
89 "net"
@@ -59,8 +60,8 @@ func (s *Server) Stop() {
5960
6061 PerformConcurrently (
6162 func () { _ = s .commandHandler .Close () },
62- func () { _ = s . httpServer . Shutdown (ctx ) },
63- func () { _ = s . httpsServer . Shutdown (ctx ) },
63+ func () { s . stopHTTPServer (ctx , s . httpServer ) },
64+ func () { s . stopHTTPServer (ctx , s . httpsServer ) },
6465 )
6566
6667 slog .Info ("Server stopped" )
@@ -131,3 +132,14 @@ func (s *Server) buildHandler() http.Handler {
131132
132133 return handler
133134}
135+
136+ func (s * Server ) stopHTTPServer (ctx context.Context , server * http.Server ) {
137+ err := server .Shutdown (ctx )
138+ if err != nil {
139+ if errors .Is (err , context .DeadlineExceeded ) {
140+ slog .Warn ("Closing active connections" )
141+ } else {
142+ slog .Error ("Error while attempting to stop server" , "error" , err )
143+ }
144+ }
145+ }
You can’t perform that action at this time.
0 commit comments