()
| 395 | } |
| 396 | |
| 397 | func (c *Cloud) run() { |
| 398 | log.Infof("cloud (%s) started", c.basicInfo.Name, logger.NewORGPrefix(c.orgID)) |
| 399 | |
| 400 | if err := c.platform.CheckAuth(); err != nil { |
| 401 | log.Errorf("cloud (%+v) check auth failed", c.basicInfo, logger.NewORGPrefix(c.orgID)) |
| 402 | } |
| 403 | |
| 404 | // execute immediately upon startup |
| 405 | if c.dailyTrigger() { |
| 406 | c.getCloudData() |
| 407 | } |
| 408 | |
| 409 | cloudGatherInterval := c.getCloudGatherInterval() |
| 410 | c.basicInfo.Interval = cloudGatherInterval |
| 411 | ticker := time.NewTicker(time.Second * time.Duration(cloudGatherInterval)) |
| 412 | defer ticker.Stop() |
| 413 | |
| 414 | for { |
| 415 | select { |
| 416 | case <-ticker.C: |
| 417 | if c.synchronizing { |
| 418 | continue |
| 419 | } |
| 420 | if !c.dailyTrigger() { |
| 421 | continue |
| 422 | } |
| 423 | c.getCloudData() |
| 424 | case <-c.cCtx.Done(): |
| 425 | log.Infof("cloud (%s) stopped", c.basicInfo.Name, logger.NewORGPrefix(c.orgID)) |
| 426 | return |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | func (c *Cloud) startKubernetesGatherTask() { |
| 432 | log.Infof("cloud (%s) kubernetes gather task started", c.basicInfo.Name, logger.NewORGPrefix(c.orgID)) |
no test coverage detected