Fix for #3312 sigpanic in TargetManager (#3420)

This commit is contained in:
Krasi Georgiev 2017-11-07 15:56:00 +00:00 committed by Brian Brazil
parent f689476b33
commit 08a012ccd7
1 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,7 @@ type TargetManager struct {
// Set of unqiue targets by scrape configuration.
targetSets map[string]*targetSet
logger log.Logger
starting chan struct{}
}
type targetSet struct {
@ -61,6 +62,7 @@ func NewTargetManager(app Appendable, logger log.Logger) *TargetManager {
append: app,
targetSets: map[string]*targetSet{},
logger: logger,
starting: make(chan struct{}),
}
}
@ -74,12 +76,14 @@ func (tm *TargetManager) Run() {
tm.reload()
tm.mtx.Unlock()
close(tm.starting)
tm.wg.Wait()
}
// Stop all background processing.
func (tm *TargetManager) Stop() {
<-tm.starting
level.Info(tm.logger).Log("msg", "Stopping target manager...")
tm.mtx.Lock()