forked from FinVolution/XCoder-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (29 loc) · 623 Bytes
/
main.go
File metadata and controls
33 lines (29 loc) · 623 Bytes
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
package main
import (
"context"
"errors"
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"xcoder/internal/cmd"
// 初始化 mongodb
_ "xcoder/internal/dao/mongodb"
_ "xcoder/internal/logic"
_ "xcoder/utility/xapollo"
)
func main() {
err := connData()
if err != nil {
g.Log().Errorf(context.Background(), "mysql conn error: %v", err)
panic(err)
}
cmd.Main.Run(gctx.GetInitCtx())
}
// 检查 database 连接
func connData() error {
err := g.DB().PingMaster()
if err != nil {
return errors.New("database 连接失败")
}
return nil
}