-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 910 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
package main
import (
"dispatcher/api"
"dispatcher/config"
"dispatcher/db"
"fmt"
"os"
"github.com/gin-gonic/gin"
"github.com/go-kit/kit/log"
)
func initConfig(logger log.Logger) {
// TODO get config path as flag
config.Viper().AddConfigPath("./config")
config.Viper().SetConfigName("default")
config.Viper().SetConfigType("env")
config.Viper().AutomaticEnv()
if err := config.Viper().ReadInConfig(); err != nil {
logger.Log("cannot load config file %s", err)
}
config.Parse()
}
func main() {
var logger log.Logger
{
logger = log.NewLogfmtLogger(os.Stderr)
logger = log.With(logger, "ts", log.DefaultTimestampUTC)
logger = log.With(logger, "caller", log.DefaultCaller)
}
initConfig(logger)
db := db.Connect()
router := gin.Default()
api.RegisterRouterAPI(router, logger, db)
router.Run(fmt.Sprintf("%s:%d", config.Config.HttpServer.Host, config.Config.HttpServer.Port))
}