-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathmain.go
49 lines (42 loc) · 1005 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
48
49
package main
import (
"flag"
"fmt"
"log"
"time"
"github.com/Allenxuxu/mogutouERP/models"
"github.com/Allenxuxu/mogutouERP/pkg/token"
"github.com/gin-gonic/gin"
config "github.com/micro/go-micro/config"
"github.com/micro/go-micro/config/source/file"
"github.com/pkg/browser"
)
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)
gin.DisableConsoleColor()
// gin.SetMode(gin.ReleaseMode)
r := initRouter()
go func() {
time.Sleep(time.Second)
browser.OpenURL("http://127.0.0.1:1988/ui")
fmt.Println("Open: http://127.0.0.1:1988/ui")
}()
r.Run(":1988") // listen and serve on 0.0.0.0:8080
}