cron: Start server before tasks have finished

This commit is contained in:
Tom Wiesing 2023-01-06 17:30:16 +01:00
parent 337a5fbeba
commit a3bd0db78c
No known key found for this signature in database

View file

@ -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)