-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (28 loc) · 873 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
package main
import (
"fmt"
"go.uber.org/zap"
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus/promhttp"
cfg "github.com/node-a-team/irisnet-validator_exporter/config"
"github.com/node-a-team/irisnet-validator_exporter/exporter"
rpc "github.com/node-a-team/irisnet-validator_exporter/getData/rpc"
)
func main() {
log, _ := zap.NewDevelopment()
defer log.Sync()
cfg.ConfigPath = os.Args[1]
port := cfg.Init()
rpc.OpenSocket(log)
http.Handle("/metrics", promhttp.Handler())
go exporter.Start(log)
err := http.ListenAndServe(":"+port, nil)
// log
if err != nil {
// handle error
log.Fatal("HTTP Handle", zap.Bool("Success", false), zap.String("err", fmt.Sprint(err)))
} else {
log.Info("HTTP Handle", zap.Bool("Success", true), zap.String("err", "nil"), zap.String("Listen&Serve", "Prometheus Handler(Port: "+port+")"))
}
}