Files
gf/net/ghttp/ghttp_server_graceful.go

30 lines
1.2 KiB
Go
Raw Permalink Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package ghttp
import "github.com/gogf/gf/v2/net/ghttp/internal/graceful"
2022-03-19 17:58:21 +08:00
// newGracefulServer creates and returns a graceful http server with a given address.
// The optional parameter `fd` specifies the file descriptor which is passed from parent server.
func (s *Server) newGracefulServer(address string, fd int) *graceful.Server {
var (
loggerWriter = &errorLogger{logger: s.config.Logger}
serverConfig = graceful.ServerConfig{
Listeners: s.config.Listeners,
Handler: s.config.Handler,
ReadTimeout: s.config.ReadTimeout,
WriteTimeout: s.config.WriteTimeout,
IdleTimeout: s.config.IdleTimeout,
GracefulShutdownTimeout: s.config.GracefulTimeout,
MaxHeaderBytes: s.config.MaxHeaderBytes,
KeepAlive: s.config.KeepAlive,
Logger: s.config.Logger,
2019-06-19 09:06:52 +08:00
}
)
return graceful.New(address, fd, loggerWriter, serverConfig)
}