-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (31 loc) · 933 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
package main
import (
"flag"
"main/src"
"net/http"
"os"
)
var (
webListenAddress = flag.String("web.listem.address", "0.0.0.0:9172", "Address to listen")
logLevel = flag.String("log.level", "info", "Only log messages with the given severity or above. One of: [debug, info, warn, error]")
logFormat = flag.String("log.format", "text", "Output format of log messages. One of: [text, json]")
)
func main() {
// Parse flags
flag.Parse()
// Init logger
src.Init(logLevel, logFormat)
logger := src.GetLogger()
logger.Info("Exporter is started")
// Start HTTP server
server := http.NewServeMux()
server.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
src.Router(writer, request, logger)
})
logger.Info("Starting HTTP server on " + *webListenAddress + "")
err := http.ListenAndServe(*webListenAddress, server)
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
}