mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-08 07:17:48 +02:00
server shutdown timeout
This commit is contained in:
1 parent
031c67dd5d
commit
48803d9a68
1 file changed
+16
-1
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/mq/kafka/protocol"
|
||||
@@ -134,7 +135,21 @@ func (s *Server) Close() error {
|
||||
if s.ln != nil {
|
||||
_ = s.ln.Close()
|
||||
}
|
||||
s.wg.Wait()
|
||||
|
||||
// Wait for goroutines to finish with a timeout to prevent hanging
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
s.wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
// Normal shutdown
|
||||
case <-time.After(2 * time.Second):
|
||||
// Timeout - force shutdown
|
||||
glog.Warningf("Server shutdown timed out after 2 seconds, forcing close")
|
||||
}
|
||||
|
||||
// Close the handler (important for SeaweedMQ mode)
|
||||
if s.handler != nil {
|
||||
|
||||
Reference in new issue
Block a user