diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index af9edfd5c..e0c389801 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -193,7 +193,7 @@ func (s *Server) Start() error { // If this is a child process, it then notifies its parent exit. if gproc.IsChild() { - gtimer.SetTimeout(2*time.Second, func() { + gtimer.SetTimeout(time.Duration(s.config.GracefulTimeout) * time.Second, func() { if err := gproc.Send(gproc.PPid(), []byte("exit"), adminGProcCommGroup); err != nil { //glog.Error("server error in process communication:", err) } diff --git a/net/ghttp/ghttp_server_config.go b/net/ghttp/ghttp_server_config.go index 760b17b43..7a59f7726 100644 --- a/net/ghttp/ghttp_server_config.go +++ b/net/ghttp/ghttp_server_config.go @@ -218,6 +218,9 @@ type ServerConfig struct { // Graceful enables graceful reload feature for all servers of the process. Graceful bool `json:"graceful"` + + // GracefulTimeout set the maximum survival time (seconds) of the parent process. + GracefulTimeout uint8 `json:"gracefulTimeout"` } // Deprecated. Use NewConfig instead. @@ -265,6 +268,7 @@ func NewConfig() ServerConfig { FormParsingMemory: 1024 * 1024, // 1MB Rewrites: make(map[string]string), Graceful: false, + GracefulTimeout: 2, // seconds } }