1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 18:40:49 +00:00

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

实际上如果没有使用graceful启动,这些init的工作完全没用
当然其他模块也应该存在这样的工作,比如session中的sess_utils.go中的init工作
This commit is contained in:
nkbai 2015-11-30 16:15:35 +08:00
parent 2c8cb5693e
commit 74ebcd28b2

View File

@ -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() {