Refactor how to handle sigterm and nginx process goroutine (#4959)
This commit is contained in:
parent
12aa72622a
commit
66ef05849f
2 changed files with 10 additions and 10 deletions
|
@ -125,23 +125,22 @@ func main() {
|
|||
}
|
||||
mc.Start()
|
||||
|
||||
ngx := controller.NewNGINXController(conf, mc)
|
||||
go handleSigterm(ngx, func(code int) {
|
||||
os.Exit(code)
|
||||
})
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
if conf.EnableProfiling {
|
||||
go registerProfiler()
|
||||
}
|
||||
|
||||
ngx := controller.NewNGINXController(conf, mc)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
registerHealthz(nginx.HealthPath, ngx, mux)
|
||||
registerMetrics(reg, mux)
|
||||
|
||||
go startHTTPServer(conf.ListenPorts.Health, mux)
|
||||
go ngx.Start()
|
||||
|
||||
ngx.Start()
|
||||
handleSigterm(ngx, func(code int) {
|
||||
os.Exit(code)
|
||||
})
|
||||
}
|
||||
|
||||
type exiter func(code int)
|
||||
|
|
|
@ -334,7 +334,7 @@ func (n *NGINXController) Start() {
|
|||
select {
|
||||
case err := <-n.ngxErrCh:
|
||||
if n.isShuttingDown {
|
||||
break
|
||||
return
|
||||
}
|
||||
|
||||
// if the nginx master process dies the workers continue to process requests,
|
||||
|
@ -358,6 +358,7 @@ func (n *NGINXController) Start() {
|
|||
if n.isShuttingDown {
|
||||
break
|
||||
}
|
||||
|
||||
if evt, ok := event.(store.Event); ok {
|
||||
klog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
|
||||
if evt.Type == store.ConfigurationEvent {
|
||||
|
@ -371,7 +372,7 @@ func (n *NGINXController) Start() {
|
|||
klog.Warningf("Unexpected event type received %T", event)
|
||||
}
|
||||
case <-n.stopCh:
|
||||
break
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue