From a3bd0db78c55a9ee894c8e7f0a901f6f948912b3 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Fri, 6 Jan 2023 17:30:16 +0100 Subject: [PATCH] cron: Start server before tasks have finished --- internal/dis/component/control/cron/cron.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/dis/component/control/cron/cron.go b/internal/dis/component/control/cron/cron.go index 952c430..36b2584 100644 --- a/internal/dis/component/control/cron/cron.go +++ b/internal/dis/component/control/cron/cron.go @@ -94,7 +94,7 @@ func (control *Cron) Once(ctx context.Context) { // Start invokes all cron jobs regularly, waiting between invocations as specified in configuration. // -// The first run is invoked immediatly. +// A first run is invoked immediatly. // The call to Start returns after the first invocation of all cron tasks. // // The returned channel is closed once no more cron tasks are active. @@ -111,12 +111,14 @@ func (control *Cron) Start(ctx context.Context, signal <-chan struct{}) <-chan s cleanup := make(chan struct{}) // closed once we have finished running everything - run() // run tasks immediatly - // start a new xgoroutine to run cron tasks go func() { defer close(cleanup) + zerolog.Ctx(ctx).Debug().Msg("Cron() starting first run") + run() + zerolog.Ctx(ctx).Debug().Msg("Cron() beginnning scheduling") + timer := timex.NewTimer() for { timex.StopTimer(timer)