()
| 580 | } |
| 581 | |
| 582 | func (a *application) mainLoop() { |
| 583 | ha := new(NodeFHelper) |
| 584 | comm := a.Communicator() |
| 585 | node := a.svrCfg.Node |
| 586 | app := a.svrCfg.App |
| 587 | server := a.svrCfg.Server |
| 588 | container := a.svrCfg.Container |
| 589 | ha.SetNodeInfo(comm, node, app, server, container) |
| 590 | |
| 591 | svrCfg := a.ServerConfig() |
| 592 | go ha.ReportVersion(svrCfg.Version) |
| 593 | go ha.KeepAlive("") //first start |
| 594 | go a.handleSignal() |
| 595 | // registrar service |
| 596 | ctx := context.Background() |
| 597 | go a.registryAdapters(ctx) |
| 598 | |
| 599 | loop := time.NewTicker(svrCfg.MainLoopTicker) |
| 600 | for { |
| 601 | select { |
| 602 | case <-a.shutdown: |
| 603 | ReportNotifyInfo(NotifyNormal, "stop") |
| 604 | return |
| 605 | case <-loop.C: |
| 606 | if atomic.LoadInt32(&a.isShutdowning) == 1 { |
| 607 | continue |
| 608 | } |
| 609 | for name, adapter := range a.svrCfg.Adapters { |
| 610 | if adapter.Protocol == "not_tars" { |
| 611 | // TODO not_tars support |
| 612 | ha.KeepAlive(name) |
| 613 | continue |
| 614 | } |
| 615 | if s, ok := a.goSvrs[adapter.Obj]; ok { |
| 616 | if !s.IsZombie(svrCfg.ZombieTimeout) { |
| 617 | ha.KeepAlive(name) |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | } |
no test coverage detected