From 5c3497a433c95e79b2f2df211bf8d87bf7d95c5a Mon Sep 17 00:00:00 2001 From: mudler Date: Sun, 21 Apr 2024 16:33:04 +0200 Subject: [PATCH] The bug was that we didn't reset the timer when an agent was not working as standalone' ' --- agent/agent.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 0453687..cedbf5f 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -604,9 +604,11 @@ func (a *Agent) consumeJob(job *Job, role string) { job.Result.Finish(nil) } +// This is running in the background. func (a *Agent) periodicallyRun(timer *time.Timer) { - // This is running in the background. + // Remember always to reset the timer - if we don't the agent will stop.. defer timer.Reset(a.options.periodicRuns) + if !a.options.standaloneJob { return } @@ -741,6 +743,7 @@ func (a *Agent) Run() error { } func (a *Agent) loop(timer *time.Timer, job *Job) { + // Remember always to reset the timer - if we don't the agent will stop.. defer timer.Reset(a.options.periodicRuns) // Consume the job and generate a response // TODO: Give a short-term memory to the agent