MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Start

Method Start

internal/utils/agents/manager.go:52–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func (this *Manager) Start() {
53 remotelogs.Println("AGENT_MANAGER", "starting ...")
54
55 err := this.loadDB()
56 if err != nil {
57 remotelogs.Error("AGENT_MANAGER", "load database failed: "+err.Error())
58 return
59 }
60
61 // 从本地数据库中加载
62 err = this.Load()
63 if err != nil {
64 remotelogs.Error("AGENT_MANAGER", "load failed: "+err.Error())
65 }
66
67 // 先从API获取
68 err = this.LoopAll()
69 if err != nil {
70 if rpc.IsConnError(err) {
71 remotelogs.Debug("AGENT_MANAGER", "retrieve latest agent ip failed: "+err.Error())
72 } else {
73 remotelogs.Error("AGENT_MANAGER", "retrieve latest agent ip failed: "+err.Error())
74 }
75 }
76
77 // 定时获取
78 var duration = 30 * time.Minute
79 if Tea.IsTesting() {
80 duration = 30 * time.Second
81 }
82 var ticker = time.NewTicker(duration)
83 for range ticker.C {
84 err = this.LoopAll()
85 if err != nil {
86 remotelogs.Error("AGENT_MANAGER", "retrieve latest agent ip failed: "+err.Error())
87 }
88 }
89}
90
91func (this *Manager) Load() error {
92 var offset int64 = 0

Callers

nothing calls this directly

Calls 8

loadDBMethod · 0.95
LoadMethod · 0.95
LoopAllMethod · 0.95
PrintlnFunction · 0.92
ErrorFunction · 0.92
IsConnErrorFunction · 0.92
DebugFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected