server|cmd: refactor monitors chan
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
8f5e37a83c
commit
d6c32fa88e
2 changed files with 15 additions and 15 deletions
|
@ -167,7 +167,7 @@ func catchShutdown(gserver *grpc.Server, sserver *server.Server, hserver *http.S
|
|||
gserver.GracefulStop()
|
||||
hserver.Shutdown(context.Background())
|
||||
sserver.StopStreamServer()
|
||||
sserver.StopExitMonitor()
|
||||
sserver.StopMonitors()
|
||||
if err := sserver.Shutdown(); err != nil {
|
||||
logrus.Warnf("error shutting down main service %v", err)
|
||||
}
|
||||
|
@ -515,10 +515,10 @@ func main() {
|
|||
}()
|
||||
|
||||
streamServerCloseCh := service.StreamingServerCloseChan()
|
||||
serverExitMonitorCh := service.ExitMonitorCloseChan()
|
||||
serverMonitorsCh := service.MonitorsCloseChan()
|
||||
select {
|
||||
case <-streamServerCloseCh:
|
||||
case <-serverExitMonitorCh:
|
||||
case <-serverMonitorsCh:
|
||||
case <-serverCloseCh:
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ func main() {
|
|||
|
||||
<-streamServerCloseCh
|
||||
logrus.Debug("closed stream server")
|
||||
<-serverExitMonitorCh
|
||||
<-serverMonitorsCh
|
||||
logrus.Debug("closed exit monitor")
|
||||
<-serverCloseCh
|
||||
logrus.Debug("closed main server")
|
||||
|
|
|
@ -66,9 +66,9 @@ type Server struct {
|
|||
appArmorEnabled bool
|
||||
appArmorProfile string
|
||||
|
||||
bindAddress string
|
||||
stream streamService
|
||||
exitMonitorChan chan struct{}
|
||||
bindAddress string
|
||||
stream streamService
|
||||
monitorsChan chan struct{}
|
||||
}
|
||||
|
||||
// StopStreamServer stops the stream server
|
||||
|
@ -211,7 +211,7 @@ func New(config *Config) (*Server, error) {
|
|||
seccompEnabled: seccomp.IsEnabled(),
|
||||
appArmorEnabled: apparmor.IsEnabled(),
|
||||
appArmorProfile: config.ApparmorProfile,
|
||||
exitMonitorChan: make(chan struct{}),
|
||||
monitorsChan: make(chan struct{}),
|
||||
}
|
||||
|
||||
if s.seccompEnabled {
|
||||
|
@ -355,14 +355,14 @@ func (s *Server) CreateMetricsEndpoint() (*http.ServeMux, error) {
|
|||
return mux, nil
|
||||
}
|
||||
|
||||
// StopExitMonitor stops the exit monitor
|
||||
func (s *Server) StopExitMonitor() {
|
||||
close(s.exitMonitorChan)
|
||||
// StopMonitors stops al the monitors
|
||||
func (s *Server) StopMonitors() {
|
||||
close(s.monitorsChan)
|
||||
}
|
||||
|
||||
// ExitMonitorCloseChan returns the close chan for the exit monitor
|
||||
func (s *Server) ExitMonitorCloseChan() chan struct{} {
|
||||
return s.exitMonitorChan
|
||||
// MonitorsCloseChan returns the close chan for the exit monitor
|
||||
func (s *Server) MonitorsCloseChan() chan struct{} {
|
||||
return s.monitorsChan
|
||||
}
|
||||
|
||||
// StartExitMonitor start a routine that monitors container exits
|
||||
|
@ -410,7 +410,7 @@ func (s *Server) StartExitMonitor() {
|
|||
logrus.Debugf("watch error: %v", err)
|
||||
close(done)
|
||||
return
|
||||
case <-s.exitMonitorChan:
|
||||
case <-s.monitorsChan:
|
||||
logrus.Debug("closing exit monitor...")
|
||||
close(done)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue