1.statistics log

2. Handle exception : etcd keepalive failed
This commit is contained in:
wenxu12345
2022-03-09 11:25:51 +08:00
parent 0e575a9366
commit c4554cb4e9
5 changed files with 19 additions and 8 deletions
+10
View File
@@ -78,6 +78,16 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
log.Debug("", "KeepAlive kresp ok", pv)
} else {
log.Error("", "KeepAlive kresp failed", pv)
t := time.NewTicker(time.Duration(ttl) * time.Second)
for {
select {
case <-t.C:
}
if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil {
log.Error("", "etcd Put failed ", err.Error(), serviceKey, serviceValue, resp.ID)
}
log.Info("", "etcd Put ok", serviceKey, serviceValue, resp.ID)
}
}
}
}
+4 -3
View File
@@ -1,6 +1,7 @@
package statistics
import (
"Open_IM/pkg/common/log"
"time"
)
@@ -14,13 +15,13 @@ type Statistics struct {
func (s *Statistics) output() {
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
defer t.Stop()
//var sum uint64
var sum uint64
for {
//sum = *s.Count
sum = *s.Count
select {
case <-t.C:
}
//log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
}
}