bugfix: add prober.plugins Stop() for release resource (#610)

This commit is contained in:
yubo 2021-03-11 16:22:55 +08:00 committed by GitHub
parent 3e426537c7
commit 398628870c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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
}