mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:30:56 +00:00
Added hookable signals
This commit is contained in:
parent
eba6afd6fb
commit
fc4801494d
@ -85,23 +85,31 @@ var (
|
|||||||
|
|
||||||
isChild bool
|
isChild bool
|
||||||
socketOrder string
|
socketOrder string
|
||||||
once sync.Once
|
|
||||||
|
hookableSignals []os.Signal
|
||||||
)
|
)
|
||||||
|
|
||||||
func onceInit() {
|
func init() {
|
||||||
regLock = &sync.Mutex{}
|
|
||||||
flag.BoolVar(&isChild, "graceful", false, "listen on open fd (after forking)")
|
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")
|
flag.StringVar(&socketOrder, "socketorder", "", "previous initialization order - used when more than one listener was started")
|
||||||
|
|
||||||
|
regLock = &sync.Mutex{}
|
||||||
runningServers = make(map[string]*Server)
|
runningServers = make(map[string]*Server)
|
||||||
runningServersOrder = []string{}
|
runningServersOrder = []string{}
|
||||||
socketPtrOffsetMap = make(map[string]uint)
|
socketPtrOffsetMap = make(map[string]uint)
|
||||||
|
|
||||||
|
hookableSignals = []os.Signal{
|
||||||
|
syscall.SIGHUP,
|
||||||
|
syscall.SIGINT,
|
||||||
|
syscall.SIGTERM,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns a new graceServer.
|
// NewServer returns a new graceServer.
|
||||||
func NewServer(addr string, handler http.Handler) (srv *Server) {
|
func NewServer(addr string, handler http.Handler) (srv *Server) {
|
||||||
once.Do(onceInit)
|
|
||||||
regLock.Lock()
|
regLock.Lock()
|
||||||
defer regLock.Unlock()
|
defer regLock.Unlock()
|
||||||
|
|
||||||
if !flag.Parsed() {
|
if !flag.Parsed() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user