The bug was that we didn't reset the timer when an agent was not working as standalone'

'
This commit is contained in:
mudler
2024-04-21 16:33:04 +02:00
parent 9974dec2e1
commit 5c3497a433

View File

@@ -604,9 +604,11 @@ func (a *Agent) consumeJob(job *Job, role string) {
job.Result.Finish(nil) job.Result.Finish(nil)
} }
// This is running in the background.
func (a *Agent) periodicallyRun(timer *time.Timer) { 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) defer timer.Reset(a.options.periodicRuns)
if !a.options.standaloneJob { if !a.options.standaloneJob {
return return
} }
@@ -741,6 +743,7 @@ func (a *Agent) Run() error {
} }
func (a *Agent) loop(timer *time.Timer, job *Job) { 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) defer timer.Reset(a.options.periodicRuns)
// Consume the job and generate a response // Consume the job and generate a response
// TODO: Give a short-term memory to the agent // TODO: Give a short-term memory to the agent