This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1c75359bc feat(triple): add timeout for graceful stop (#2943)
1c75359bc is described below

commit 1c75359bc11a2de1933b1f1d704253f542e6781f
Author: marsevilspirit <[email protected]>
AuthorDate: Fri Jul 11 09:52:42 2025 +0800

    feat(triple): add timeout for graceful stop (#2943)
    
    * feat(triple): add timeout for graceful stop
    
    * Update common/constant/default.go
    
    Co-authored-by: Copilot <[email protected]>
    
    ---------
    
    Co-authored-by: Copilot <[email protected]>
---
 common/constant/default.go | 4 ++++
 protocol/triple/server.go  | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/constant/default.go b/common/constant/default.go
index 0b2f2d5dd..3b0a4bd6c 100644
--- a/common/constant/default.go
+++ b/common/constant/default.go
@@ -108,9 +108,13 @@ const (
        DefaultMaxCallRecvMsgSize = 1024 * 1024 * 4
        DefaultMaxCallSendMsgSize = math.MaxInt32
 
+       // keepalive
        DefaultKeepAliveInterval = "10s"
        DefaultKeepAliveTimeout  = "20s"
        MinKeepAliveInterval     = 10 * time.Second // KeepAliveMinInterval is 
the minimum ping interval to invoid too many ping
+
+       // graceful shutdown
+       DefaultGracefulShutdownTimeout = 10 * time.Second
 )
 
 const (
diff --git a/protocol/triple/server.go b/protocol/triple/server.go
index ad87b75a4..50be3ab93 100644
--- a/protocol/triple/server.go
+++ b/protocol/triple/server.go
@@ -468,7 +468,12 @@ func (s *Server) Stop() {
 
 // GracefulStop TRIPLE server
 func (s *Server) GracefulStop() {
-       _ = s.triServer.GracefulStop(context.Background())
+       shutdownCtx, cancel := context.WithTimeout(context.Background(), 
constant.DefaultGracefulShutdownTimeout)
+       defer cancel()
+
+       if err := s.triServer.GracefulStop(shutdownCtx); err != nil {
+               logger.Errorf("Triple server shutdown error: %v", err)
+       }
 }
 
 // createServiceInfoWithReflection is for non-idl scenario.

Reply via email to