修改提示日志
This commit is contained in:
parent
cb572a5d8f
commit
9ade20bbc0
@ -84,7 +84,7 @@ func (n *NatsService) subscribeUpdateService() error {
|
||||
return n.SubscribeCb(updateTopic, func(m *nats.Msg) {
|
||||
var node = &etcd.ServiceNode{}
|
||||
_ = json.Unmarshal(m.Data, node)
|
||||
//log.Debug(n.Log("发现新节点:%v", node))
|
||||
//log.Debug(n.Log("发现新节点:%v", string(m.Data)))
|
||||
// 不是同类服务不处理,是自己发出来的更新,也不处理
|
||||
if node.Type != n.Type() || node.Name == n.Name() {
|
||||
//log.Debug(n.Log("与本节点不匹配.本节点:%v", n.node))
|
||||
@ -92,9 +92,10 @@ func (n *NatsService) subscribeUpdateService() error {
|
||||
}
|
||||
// 有新服务上线,本服务准备退出
|
||||
if n.node.Version < node.Version {
|
||||
log.InfoF(n.Log("有新服务:%v,版本:%v.本服务即将关闭", node.Name, node.Version))
|
||||
n.NotifyStop()
|
||||
log.InfoF("有新服务%v auto exit, initiating shutdown...", n.Name())
|
||||
n.WaitStop()
|
||||
|
||||
//n.WaitStop()
|
||||
os.Exit(0)
|
||||
}
|
||||
})
|
||||
@ -111,7 +112,7 @@ func (n *NatsService) subscribeRpc() error {
|
||||
})
|
||||
}
|
||||
|
||||
// 订阅回调
|
||||
// 订阅回调 cb会切回service协程执行,避免在cb中有阻塞式请求
|
||||
func (n *NatsService) SubscribeCb(topic string, cb func(m *nats.Msg)) error {
|
||||
return n.nats.SubscribeCb(topic, func(m *nats.Msg) {
|
||||
n.RunOnce(func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user