Unique client id and fix graceful shutdown

This commit is contained in:
Daniel Pupius
2025-05-04 13:26:13 -07:00
parent 3ce8889786
commit df7df6dbd6
3 changed files with 16 additions and 11 deletions
+10 -7
View File
@@ -96,15 +96,18 @@ func (s *Server) Start() error {
// Stop shuts down the server
func (s *Server) Stop() error {
// Set the shutdown flag first to prevent new connections from starting streams
s.isShuttingDown.Store(true)
if !s.isShuttingDown.Load() {
s.logger.Info("Stopping server...")
// Set the shutdown flag first to prevent new connections from starting streams
s.isShuttingDown.Store(true)
// Signal all active connections to close
close(s.shutdown)
// Signal all active connections to close
close(s.shutdown)
// Then shut down the HTTP server
if s.server != nil {
return s.server.Shutdown()
// Then shut down the HTTP server
if s.server != nil {
return s.server.Shutdown()
}
}
return nil
}