bugfix: add prober.plugins Stop() for release resource (#610)
This commit is contained in:
parent
3e426537c7
commit
398628870c
|
@ -166,6 +166,10 @@ func (p *collectRule) update(rule *models.CollectRule) error {
|
|||
|
||||
logger.Debugf("update %s", rule)
|
||||
|
||||
if si, ok := p.input.(telegraf.ServiceInput); ok {
|
||||
si.Stop()
|
||||
}
|
||||
|
||||
input, err := telegrafInput(rule)
|
||||
if err != nil {
|
||||
// ignore error, use old config
|
||||
|
|
|
@ -76,6 +76,15 @@ func (p *manager) loop() {
|
|||
}()
|
||||
}
|
||||
|
||||
func (p *manager) deleteRule(id int64) {
|
||||
if rule, ok := p.index[id]; ok {
|
||||
if si, ok := rule.input.(telegraf.ServiceInput); ok {
|
||||
si.Stop()
|
||||
}
|
||||
delete(p.index, id)
|
||||
}
|
||||
}
|
||||
|
||||
// schedule return until there are no jobs
|
||||
func (p *manager) schedule() error {
|
||||
for {
|
||||
|
@ -91,7 +100,7 @@ func (p *manager) schedule() error {
|
|||
latestRule, ok := p.cache.Get(summary.id)
|
||||
if !ok {
|
||||
// drop it if not exist in cache
|
||||
delete(p.index, summary.id)
|
||||
p.deleteRule(summary.id)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue