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
| package main
import (
"flag"
"log"
"github.com/bobacgo/kit/app"
"github.com/bobacgo/kit/app/conf"
"github.com/bobacgo/kit/examples/config"
"github.com/bobacgo/kit/examples/internal/app/router"
)
var filepath = flag.String("config", "./config.yaml", "config file path")
func init() {
flag.String("name", "admin-service", "service name")
flag.String("env", "dev", "run config context")
flag.String("logger.level", "info", "logger level")
flag.Int("port", 8080, "http port 8080, rpc port 9080")
conf.BindPFlags()
}
func main() {
newApp := app.New(*filepath,
app.WithScanConfig(config.Cfg),
app.WithLogger(),
app.WithMustLocalCache(),
// app.WithMustDB(),
// app.WithMustRedis(),
app.WithGinServer(router.Register),
)
if err := newApp.Run(); err != nil {
log.Panic(err.Error())
}
}
|