Avoid goroutine leak in server
This commit is contained in:
parent
e4bb506ace
commit
74ace58ae1
|
@ -248,7 +248,9 @@ func (s *Server) Start() {
|
||||||
s.listenConfigurations(stop)
|
s.listenConfigurations(stop)
|
||||||
})
|
})
|
||||||
s.startProvider()
|
s.startProvider()
|
||||||
go s.listenSignals()
|
s.routinesPool.Go(func(stop chan bool) {
|
||||||
|
s.listenSignals(stop)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartWithContext starts the server and Stop/Close it when context is Done
|
// StartWithContext starts the server and Stop/Close it when context is Done
|
||||||
|
|
|
@ -447,10 +447,12 @@ func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish ch
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
case nextConfig := <-ring.Out():
|
case nextConfig := <-ring.Out():
|
||||||
publish <- nextConfig.(types.ConfigMessage)
|
if config, ok := nextConfig.(types.ConfigMessage); ok {
|
||||||
|
publish <- config
|
||||||
time.Sleep(throttle)
|
time.Sleep(throttle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -13,9 +13,12 @@ func (s *Server) configureSignals() {
|
||||||
signal.Notify(s.signals, syscall.SIGUSR1)
|
signal.Notify(s.signals, syscall.SIGUSR1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) listenSignals() {
|
func (s *Server) listenSignals(stop chan bool) {
|
||||||
for {
|
for {
|
||||||
sig := <-s.signals
|
select {
|
||||||
|
case <-stop:
|
||||||
|
return
|
||||||
|
case sig := <-s.signals:
|
||||||
switch sig {
|
switch sig {
|
||||||
case syscall.SIGUSR1:
|
case syscall.SIGUSR1:
|
||||||
log.Infof("Closing and re-opening log files for rotation: %+v", sig)
|
log.Infof("Closing and re-opening log files for rotation: %+v", sig)
|
||||||
|
@ -31,4 +34,5 @@ func (s *Server) listenSignals() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@ package server
|
||||||
|
|
||||||
func (s *Server) configureSignals() {}
|
func (s *Server) configureSignals() {}
|
||||||
|
|
||||||
func (s *Server) listenSignals() {}
|
func (s *Server) listenSignals(stop chan bool) {}
|
||||||
|
|
Loading…
Reference in a new issue