forked from prebid/prebid-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 978 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 (
"os"
log "github.com/sirupsen/logrus"
backendConfig "github.com/prebid/prebid-cache/backends/config"
"github.com/prebid/prebid-cache/config"
"github.com/prebid/prebid-cache/endpoints/routing"
"github.com/prebid/prebid-cache/metrics"
"github.com/prebid/prebid-cache/server"
)
const configFileName = "config"
func main() {
log.SetOutput(os.Stdout)
cfg := config.NewConfig(configFileName)
setLogLevel(cfg.Log.Level)
cfg.ValidateAndLog()
appMetrics := metrics.CreateMetrics(cfg)
backend := backendConfig.NewBackend(cfg, appMetrics)
publicHandler := routing.NewPublicHandler(cfg, backend, appMetrics)
adminHandler := routing.NewAdminHandler(cfg, backend, appMetrics)
go appMetrics.Export(cfg)
server.Listen(cfg, publicHandler, adminHandler, appMetrics)
}
func setLogLevel(logLevel config.LogLevel) {
level, err := log.ParseLevel(string(logLevel))
if err != nil {
log.Fatalf("Invalid logrus level: %v", err)
}
log.SetLevel(level)
}