Merge pull request #1214 from ansionfor/add-graceful-timeout

add graceful reload timeout config
This commit is contained in:
John Guo 2021-04-10 08:23:54 +08:00 committed by GitHub
commit fb48ceeeee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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)
}

View File

@ -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
}
}