mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Cleanup/fix program termination sequence.
Change-Id: I2bc58a2583fb079c9ef383cfc7a5e0fbe613f1cd
This commit is contained in:
parent
6947ee9bc9
commit
fb44580110
6
main.go
6
main.go
|
@ -85,6 +85,7 @@ type prometheus struct {
|
||||||
unwrittenSamples chan *extraction.Result
|
unwrittenSamples chan *extraction.Result
|
||||||
|
|
||||||
ruleManager rules.RuleManager
|
ruleManager rules.RuleManager
|
||||||
|
targetManager retrieval.TargetManager
|
||||||
notifications chan notification.NotificationReqs
|
notifications chan notification.NotificationReqs
|
||||||
storage *metric.TieredStorage
|
storage *metric.TieredStorage
|
||||||
|
|
||||||
|
@ -174,11 +175,15 @@ func (p *prometheus) close() {
|
||||||
p.deletionTimer.Stop()
|
p.deletionTimer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop any currently active curation (deletion or compaction).
|
||||||
if len(p.stopBackgroundOperations) == 0 {
|
if len(p.stopBackgroundOperations) == 0 {
|
||||||
p.stopBackgroundOperations <- true
|
p.stopBackgroundOperations <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
p.ruleManager.Stop()
|
p.ruleManager.Stop()
|
||||||
|
p.targetManager.Stop()
|
||||||
|
close(p.unwrittenSamples)
|
||||||
|
|
||||||
p.storage.Close()
|
p.storage.Close()
|
||||||
|
|
||||||
close(p.notifications)
|
close(p.notifications)
|
||||||
|
@ -294,6 +299,7 @@ func main() {
|
||||||
stopBackgroundOperations: make(chan bool, 1),
|
stopBackgroundOperations: make(chan bool, 1),
|
||||||
|
|
||||||
ruleManager: ruleManager,
|
ruleManager: ruleManager,
|
||||||
|
targetManager: targetManager,
|
||||||
notifications: notifications,
|
notifications: notifications,
|
||||||
storage: ts,
|
storage: ts,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ type TargetManager interface {
|
||||||
ReplaceTargets(job config.JobConfig, newTargets []Target)
|
ReplaceTargets(job config.JobConfig, newTargets []Target)
|
||||||
Remove(t Target)
|
Remove(t Target)
|
||||||
AddTargetsFromConfig(config config.Config)
|
AddTargetsFromConfig(config config.Config)
|
||||||
|
Stop()
|
||||||
Pools() map[string]*TargetPool
|
Pools() map[string]*TargetPool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +116,13 @@ func (m *targetManager) AddTargetsFromConfig(config config.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *targetManager) Stop() {
|
||||||
|
glog.Info("Target manager exiting...")
|
||||||
|
for _, p := range m.poolsByJob {
|
||||||
|
p.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// XXX: Not really thread-safe. Only used in /status page for now.
|
// XXX: Not really thread-safe. Only used in /status page for now.
|
||||||
func (m *targetManager) Pools() map[string]*TargetPool {
|
func (m *targetManager) Pools() map[string]*TargetPool {
|
||||||
return m.poolsByJob
|
return m.poolsByJob
|
||||||
|
|
|
@ -47,6 +47,7 @@ func NewTargetPool(m TargetManager, p TargetProvider) *TargetPool {
|
||||||
addTargetQueue: make(chan Target, targetAddQueueSize),
|
addTargetQueue: make(chan Target, targetAddQueueSize),
|
||||||
replaceTargetsQueue: make(chan targets, targetReplaceQueueSize),
|
replaceTargetsQueue: make(chan targets, targetReplaceQueueSize),
|
||||||
targetProvider: p,
|
targetProvider: p,
|
||||||
|
done: make(chan bool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ func (m *ruleManager) Run() {
|
||||||
m.runIteration(m.results)
|
m.runIteration(m.results)
|
||||||
evalDurations.Add(map[string]string{intervalKey: m.interval.String()}, float64(time.Since(start)/time.Millisecond))
|
evalDurations.Add(map[string]string{intervalKey: m.interval.String()}, float64(time.Since(start)/time.Millisecond))
|
||||||
case <-m.done:
|
case <-m.done:
|
||||||
glog.Info("RuleManager exiting...")
|
glog.Info("Rule manager exiting...")
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue