-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (41 loc) · 1.16 KB
/
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
package main
import (
"log"
"net/http"
"github.com/lacazethomas/nicehash-exporter/config"
"github.com/lacazethomas/nicehash-exporter/route"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
)
func main() {
var logger *zap.Logger
var err error
appConfig := config.GetAppConfig()
// Set log level
if appConfig.IsDev() {
logger, err = zap.NewDevelopment()
} else {
logger, err = zap.NewProduction()
}
if err != nil {
log.Println("Error to initialize logger")
}
defer logger.Sync()
zap.ReplaceGlobals(logger)
metrics := initMetrics()
prometheus.Register(metrics.temperatureDevice)
prometheus.Register(metrics.temperatureVRAM)
prometheus.Register(metrics.walletBalance)
prometheus.Register(metrics.unpaidAmount)
prometheus.Register(metrics.miningSpeed)
prometheus.Register(metrics.feerules)
getMetrics(appConfig, metrics)
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/api/mining", route.HandleMining)
http.HandleFunc("/api/status", route.HandleStatus)
err = http.ListenAndServe(":9159", nil)
if err != nil {
Check("Unable to open stocket", err)
}
}