-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 950 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 (
"github.com/lupguo/wisdom-httpd/app/infra/conf"
"github.com/lupguo/wisdom-httpd/httpd"
"github.com/lupguo/wisdom-httpd/internal/log"
"github.com/spf13/pflag"
)
// flag
var (
configFile = pflag.StringP("conf", "c", "./config.yaml", "Application configuration YAML file name")
)
func main() {
pflag.Parse()
// 应用配置
cfg, err := conf.ParseConfig(*configFile)
if err != nil {
log.Fatalf("parse config file %s got err: %s", configFile, err)
}
// 日志配置
if err = log.InitServerLog(cfg.LogConfig); err != nil {
log.Fatalf("init server log got err: %s", err)
}
// API服务初始化
apiHandler, err := NewWisdomAPIHandler()
if err != nil {
log.Fatalf("create api handler got err: %s", err)
}
svr, err := httpd.NewHttpdServer(cfg, apiHandler)
if err != nil {
log.Fatalf("new httpd server got err, %s", err)
}
// http server start
log.Fatalf("http server start fail: %s", svr.Start())
}