mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix bug : etcd Put failed etcdserver: requested lease not found
This commit is contained in:
parent
c1cda2d536
commit
60950f056b
@ -78,15 +78,25 @@ 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)
|
||||
t := time.NewTicker(time.Duration(ttl/2) * time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
}
|
||||
ctx, _ := context.WithCancel(context.Background())
|
||||
resp, err := cli.Grant(ctx, int64(ttl))
|
||||
if err != nil {
|
||||
log.Error("", "Grant failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil {
|
||||
log.Error("", "etcd Put failed ", err.Error(), serviceKey, serviceValue, resp.ID)
|
||||
continue
|
||||
} else {
|
||||
log.Info("", "etcd Put ok", serviceKey, serviceValue, resp.ID)
|
||||
}
|
||||
log.Info("", "etcd Put ok", serviceKey, serviceValue, resp.ID)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user