Commit fe793910 authored by hujiebin's avatar hujiebin

feat:连上consul,才做服务发现

parent 8e3bcea7
......@@ -102,9 +102,7 @@ func init() {
}
mylogrus.MyLog.Infof("userCenterAddr:%v,addr:%v", userCenterAddr, addrs)
}
}
mylogrus.MyLog.Infof("connect userCenterAddr:%v", userCenterAddr)
resolver.Register(bd)
resolver.Register(bd) // 服务注册
go func() {
address := consulapi.DefaultConfig().Address // 用consul api的default config
if err := consul.RegisterWatcher("services", nil, address, func(serviceStatus map[string]map[string][]string) {
......@@ -129,6 +127,8 @@ func init() {
mylogrus.MyLog.Errorf("启动 consul 的watch监控失败")
}
}()
}
mylogrus.MyLog.Infof("connect userCenterAddr:%v", userCenterAddr)
//userCenterAddr := services[0].Address + ":" + strconv.Itoa(services[0].ServicePort)
//mylogrus.MyLog.Printf("Choose userCenter %s, %s, weights: %v\n", services[0].ID, userCenterAddr, services[0].ServiceWeights)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment