Start starts job main loop.
()
| 313 | |
| 314 | // Start starts job main loop. |
| 315 | func (j *Job) Start() { |
| 316 | j.stopCtrl.markStarted() |
| 317 | j.running.Store(true) |
| 318 | if j.functionOnly { |
| 319 | j.Info("started in function-only mode") |
| 320 | } else { |
| 321 | j.Infof("started, data collection interval %ds", j.updateEvery) |
| 322 | } |
| 323 | defer func() { |
| 324 | j.running.Store(false) |
| 325 | j.stopCtrl.markStopped() |
| 326 | j.Info("stopped") |
| 327 | }() |
| 328 | |
| 329 | LOOP: |
| 330 | for { |
| 331 | select { |
| 332 | case <-j.stopCtrl.stopCh: |
| 333 | break LOOP |
| 334 | case t := <-j.tick: |
| 335 | if !j.functionOnly && j.shouldCollect(t) { |
| 336 | markRunStartWithResumeLog(&j.skipTracker, j.Logger) |
| 337 | |
| 338 | j.runOnce() |
| 339 | |
| 340 | j.skipTracker.MarkRunStop(time.Now()) |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | j.module.Cleanup(context.TODO()) |
| 345 | j.Cleanup() |
| 346 | } |
| 347 | |
| 348 | // Stop stops job main loop. It blocks until the job is stopped. |
| 349 | func (j *Job) Stop() { |
nothing calls this directly
no test coverage detected