Commit 74ebcd28 authored by nkbai's avatar nkbai

grace init中的工作可以延后进行

实际上如果没有使用graceful启动,这些init的工作完全没用
当然其他模块也应该存在这样的工作,比如session中的sess_utils.go中的init工作
parent 2c8cb569
......@@ -86,23 +86,25 @@ var (
isChild bool
socketOrder string
once sync.Once=sync.Once{}
)
func init() {
DefaultMaxHeaderBytes = 0
DefaultTimeout = 60 * time.Second
}
func onceInit(){
regLock = &sync.Mutex{}
flag.BoolVar(&isChild, "graceful", false, "listen on open fd (after forking)")
flag.StringVar(&socketOrder, "socketorder", "", "previous initialization order - used when more than one listener was started")
runningServers = make(map[string]*Server)
runningServersOrder = []string{}
socketPtrOffsetMap = make(map[string]uint)
DefaultMaxHeaderBytes = 0
DefaultTimeout = 60 * time.Second
}
// NewServer returns a new graceServer.
func NewServer(addr string, handler http.Handler) (srv *Server) {
once.Do(onceInit)
regLock.Lock()
defer regLock.Unlock()
if !flag.Parsed() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment