-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
44 lines (36 loc) · 1.03 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
package main
import (
"net/http"
"time"
"github.com/sirupsen/logrus"
"github.com/thunderbottom/aws-exporter/config"
)
var (
// Cfg is an instance of Config containing the app configuration
Cfg = config.GetConfig()
// Logger is an instance of logrus.Logger to be used throughout the exporter
Logger = getLogger()
)
func getLogger() *logrus.Logger {
logger := logrus.New()
logger.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
logger.SetLevel(logrus.InfoLevel)
return logger
}
func main() {
router := http.NewServeMux()
router.Handle("/", http.HandlerFunc(defaultHandler))
router.Handle("/metrics", http.HandlerFunc(metricsHandler))
server := &http.Server{
Addr: Cfg.Server.Address,
Handler: router,
ReadTimeout: Cfg.Server.ReadTimeout * time.Millisecond,
WriteTimeout: Cfg.Server.WriteTimeout * time.Millisecond,
}
Logger.Infof("Starting server. Listening on: %v", Cfg.Server.Address)
if err := server.ListenAndServe(); err != nil {
Logger.Fatalf("error starting server: %v", err)
}
}