mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
// 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"
|
|
|
|
// 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,
|
|
}
|
|
)
|
|
return graceful.New(address, fd, loggerWriter, serverConfig)
|
|
}
|