-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (38 loc) · 912 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
40
41
42
43
44
45
46
47
48
49
package main
import (
"os"
"github.com/rs/zerolog"
"go-hlstats/config"
"go-hlstats/modules/render"
"go-hlstats/router"
"go-hlstats/store/mysql"
"github.com/labstack/echo/v4"
)
func main() {
log := zerolog.New(os.Stderr).With().Timestamp().Logger()
conf, err := config.Load()
if err != nil {
log.Fatal().Err(err).Msg("msg")
}
e := echo.New()
e.HideBanner = true
e.HidePort = true
r, err := render.New(conf)
if err != nil {
log.Fatal().Err(err).Msg("init render error")
return
}
e.Renderer = r
if conf.Debug {
render.TemplateUpdater(e, conf, log)
}
e.Static("/public/*", "public/main/static")
store, err := mysql.New(conf.DBUrl)
if err != nil {
log.Fatal().Err(err).Msg("init store error")
return
}
router.RegisterHandlers(e, store, log)
log.Info().Str("port", conf.Port).Bool("debug", conf.Debug).Msg("Starting server")
e.Logger.Fatal(e.Start(":" + conf.Port))
}