|
@@ -4,23 +4,24 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "app.yhyue.com/moapp/MessageCenter/entity"
|
|
|
"app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
|
|
|
"app.yhyue.com/moapp/MessageCenter/rpc/internal/server"
|
|
|
"app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
|
|
|
"app.yhyue.com/moapp/MessageCenter/rpc/message"
|
|
|
"flag"
|
|
|
"fmt"
|
|
|
- _ "github.com/go-sql-driver/mysql"
|
|
|
- "github.com/go-xorm/xorm"
|
|
|
+ clientv3 "go.etcd.io/etcd/client/v3"
|
|
|
"log"
|
|
|
+ "time"
|
|
|
|
|
|
+ _ "app.yhyue.com/moapp/MessageCenter/rpc/db"
|
|
|
"github.com/tal-tech/go-zero/core/conf"
|
|
|
"github.com/tal-tech/go-zero/zrpc"
|
|
|
"google.golang.org/grpc"
|
|
|
)
|
|
|
|
|
|
var configFile = flag.String("f", "etc/message.yaml", "the config file")
|
|
|
+var EtcdCli *clientv3.Client
|
|
|
|
|
|
func main() {
|
|
|
flag.Parse()
|
|
@@ -43,13 +44,14 @@ func main() {
|
|
|
func init() {
|
|
|
conf.MustLoad(*configFile, &config.ConfigJson)
|
|
|
var err error
|
|
|
- log.Println(config.ConfigJson.DataSource)
|
|
|
- entity.Engine, err = xorm.NewEngine("mysql", config.ConfigJson.DataSource)
|
|
|
- log.Println(err)
|
|
|
- entity.Engine.ShowSQL(true)
|
|
|
+ EtcdCli, err = clientv3.New(clientv3.Config{
|
|
|
+ Endpoints: config.ConfigJson.Etcd.Hosts,
|
|
|
+ DialTimeout: 5 * time.Second,
|
|
|
+ })
|
|
|
if err != nil {
|
|
|
- log.Fatal("数据库连接失败:", err)
|
|
|
+ log.Printf("connect to etcd failed, err:%v\n", err)
|
|
|
+ return
|
|
|
}
|
|
|
- fmt.Println(config.ConfigJson.DataSource + "链接成功")
|
|
|
+ log.Println("connect to etcd success")
|
|
|
|
|
|
}
|