Close running outputs when reloading (#8769)

This commit is contained in:
viperstars 2021-03-17 03:50:56 +08:00 committed by GitHub
parent 89f5e8a9d9
commit 71757e8039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -446,6 +446,13 @@ func stopServiceInputs(inputs []*models.RunningInput) {
}
}
// stopRunningOutputs stops all running outputs.
func stopRunningOutputs(outputs []*models.RunningOutput) {
for _, output := range outputs {
output.Close()
}
}
// gather runs an input's gather function periodically until the context is
// done.
func (a *Agent) gatherLoop(
@ -784,6 +791,9 @@ func (a *Agent) runOutputs(
cancel()
wg.Wait()
log.Println("I! [agent] Stopping running outputs")
stopRunningOutputs(unit.outputs)
return nil
}