-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (34 loc) · 776 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
package main
import (
"flag"
"net/http"
_ "net/http/pprof"
log "github.com/sirupsen/logrus"
_ "go.uber.org/automaxprocs"
"github.com/xdhuxc/xdhuxc-message/src/api"
"github.com/xdhuxc/xdhuxc-message/src/conf"
)
var cf = flag.String("conf", "conf.prod.yaml", "config path")
func main() {
go func() {
log.Println(http.ListenAndServe("0.0.0.0:8005", nil))
}()
flag.Parse()
c, err := conf.InitConfiguration(*cf)
if err != nil {
log.Fatalf("init config error: %v", err)
return
}
switch c.Log.Format {
case "json":
log.SetFormatter(&log.JSONFormatter{})
default:
log.SetFormatter(&log.TextFormatter{})
}
level, _ := log.ParseLevel(c.Log.Level)
log.SetLevel(level)
app := api.NewRouter()
if err := app.Run(); err != nil {
log.Fatal(err)
}
}