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

Function init

internal/utils/idles/run.go:31–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31func init() {
32 if !teaconst.IsMain {
33 return
34 }
35
36 // recover from cache
37 {
38 data, err := os.ReadFile(Tea.Root + "/data/" + cacheFile)
39 if err == nil {
40 err = json.Unmarshal(data, &hourlyLoadMap)
41 if err == nil {
42 calculateMinLoadHours()
43 }
44 }
45 }
46
47 goman.New(func() {
48 var ticker = time.NewTicker(1 * time.Hour)
49 for range ticker.C {
50 CheckHourlyLoad(time.Now().Hour())
51 }
52 })
53}
54
55func CheckHourlyLoad(hour int) {
56 avgLoad, err := load.Avg()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
calculateMinLoadHoursFunction · 0.85
CheckHourlyLoadFunction · 0.85
HourMethod · 0.80

Tested by

no test coverage detected