Start launches a goroutine per job. Subsequent calls are no-ops. On daemon restart a new Cron should be created.
(ctx context.Context)
| 100 | // Start launches a goroutine per job. Subsequent calls are no-ops. |
| 101 | // On daemon restart a new Cron should be created. |
| 102 | func (c *Cron) Start(ctx context.Context) { |
| 103 | c.startOnce.Do(func() { |
| 104 | c.started.Store(true) |
| 105 | ctx, c.cancel = context.WithCancel(ctx) |
| 106 | for _, job := range c.jobs { |
| 107 | c.wg.Add(1) |
| 108 | pproflabel.Go(ctx, pproflabel.Service(pproflabel.ServiceUsageEventCron, "job", job.Name), func(ctx context.Context) { |
| 109 | c.run(ctx, job) |
| 110 | }) |
| 111 | } |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | // Close cancels all jobs and waits for goroutines to exit. |
| 116 | func (c *Cron) Close() error { |