-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (42 loc) · 1004 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"Chainflow/irisnet-public/config"
"Chainflow/irisnet-public/server"
"fmt"
"log"
"sync"
"time"
client "github.com/influxdata/influxdb1-client/v2"
)
func main() {
cfg, err := config.ReadConfigFromFile()
if err != nil {
log.Fatal(err)
}
c, err := client.NewHTTPClient(client.HTTPConfig{
Addr: fmt.Sprintf("http://localhost:%s", cfg.InfluxDB.Port),
Username: cfg.InfluxDB.Username,
Password: cfg.InfluxDB.Password,
})
var wg sync.WaitGroup
wg.Add(1)
// Calling go routine to send alerts for missed blocks
go func() {
for {
if err := server.GetMissedBlocks(cfg, c); err != nil {
fmt.Println("Error while sending missed block alerts", err)
}
time.Sleep(4 * time.Second)
}
}()
// Calling go routine to send alert about validator status
go func() {
for {
if err := server.ValidatorStatusAlert(cfg); err != nil {
fmt.Println("Error while sending jailed alerts", err)
}
time.Sleep(60 * time.Second)
}
}()
wg.Wait()
}