forked from Allenxuxu/mogutouERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (40 loc) · 976 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
package main
import (
"flag"
"log"
"github.com/Allenxuxu/mogutouERP/models"
"github.com/Allenxuxu/mogutouERP/pkg/token"
"github.com/gin-gonic/gin"
_ "github.com/jinzhu/gorm/dialects/mysql"
config "github.com/micro/go-micro/config"
"github.com/micro/go-micro/config/source/file"
)
func main() {
path := flag.String("c", "/etc/conf", "配置文件夹路径")
flag.Parse()
token.InitConfig(*path+"/jwt.json", "jwt-key")
//read config
fileSource := file.NewSource(
file.WithPath(*path + "/conf.json"),
)
conf := config.NewConfig()
err := conf.Load(fileSource)
if err != nil {
log.Fatal(err)
}
var info models.DBInfo
err = conf.Get("mysql").Scan(&info)
if err != nil {
log.Fatal(err)
}
models.Init(&info)
var listenAddr string
err = conf.Get("listen").Scan(&listenAddr)
if err != nil {
log.Fatal(err)
}
gin.DisableConsoleColor()
// gin.SetMode(gin.ReleaseMode)
r := initRouter()
r.Run(listenAddr) // listen and serve on 0.0.0.0:8080
}