mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 18:10:55 +00:00
grace init中的工作可以延后进行
实际上如果没有使用graceful启动,这些init的工作完全没用 当然其他模块也应该存在这样的工作,比如session中的sess_utils.go中的init工作
This commit is contained in:
parent
2c8cb5693e
commit
74ebcd28b2
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user