cron: Start server before tasks have finished
This commit is contained in:
parent
337a5fbeba
commit
a3bd0db78c
1 changed files with 5 additions and 3 deletions
|
|
@ -94,7 +94,7 @@ func (control *Cron) Once(ctx context.Context) {
|
||||||
|
|
||||||
// Start invokes all cron jobs regularly, waiting between invocations as specified in configuration.
|
// 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 call to Start returns after the first invocation of all cron tasks.
|
||||||
//
|
//
|
||||||
// The returned channel is closed once no more cron tasks are active.
|
// 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
|
cleanup := make(chan struct{}) // closed once we have finished running everything
|
||||||
|
|
||||||
run() // run tasks immediatly
|
|
||||||
|
|
||||||
// start a new xgoroutine to run cron tasks
|
// start a new xgoroutine to run cron tasks
|
||||||
go func() {
|
go func() {
|
||||||
defer close(cleanup)
|
defer close(cleanup)
|
||||||
|
|
||||||
|
zerolog.Ctx(ctx).Debug().Msg("Cron() starting first run")
|
||||||
|
run()
|
||||||
|
zerolog.Ctx(ctx).Debug().Msg("Cron() beginnning scheduling")
|
||||||
|
|
||||||
timer := timex.NewTimer()
|
timer := timex.NewTimer()
|
||||||
for {
|
for {
|
||||||
timex.StopTimer(timer)
|
timex.StopTimer(timer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue