-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
51 lines (41 loc) · 1.08 KB
/
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
50
51
package main
import (
"flag"
"fmt"
"github.com/liangbc-space/databus/models"
mysql_elasticsearch "github.com/liangbc-space/databus/mysql-elasticsearch"
"github.com/liangbc-space/databus/system"
"github.com/liangbc-space/databus/utils"
"github.com/liangbc-space/databus/utils/exception"
"os"
)
func init() {
exception.Try(func() {
// 初始化配置
configPath := flag.String("systemConfig", "conf/application.yaml", "system config file path")
flag.Parse()
system.LoadConfiguration(*configPath)
// 初始化mysql数据库
models.InitDB()
// 初始化redis连接池
//utils.InitRedis()
// 初始化elasticsearch链接
utils.InitElasticsearch()
}).Catch(func(ex exception.Exception) {
fmt.Printf("系统初始化异常:%s 文件:%s:%d\n",
ex.Message(), ex.File(), ex.Line(),
)
os.Exit(ex.Code())
})
}
func main() {
defer models.DB.Close()
exception.Try(func() {
mysql_elasticsearch.Run()
}).Catch(func(ex exception.Exception) {
fmt.Printf("程序执行异常:%s 文件:%s:%d\n",
ex.Message(), ex.File(), ex.Line(),
)
os.Exit(ex.Code())
})
}