From 71757e8039696d4791edf207e980f56afbc37a00 Mon Sep 17 00:00:00 2001 From: viperstars Date: Wed, 17 Mar 2021 03:50:56 +0800 Subject: [PATCH] Close running outputs when reloading (#8769) --- agent/agent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agent/agent.go b/agent/agent.go index fb2c75b902f37..3d40e74a1bcdf 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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 }