mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 02:58:26 +08:00
fix bug : etcd Put failed etcdserver: requested lease not found
This commit is contained in:
parent
c1cda2d536
commit
60950f056b
@ -78,16 +78,26 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
|
|||||||
log.Debug("", "KeepAlive kresp ok", pv)
|
log.Debug("", "KeepAlive kresp ok", pv)
|
||||||
} else {
|
} else {
|
||||||
log.Error("", "KeepAlive kresp failed", pv)
|
log.Error("", "KeepAlive kresp failed", pv)
|
||||||
t := time.NewTicker(time.Duration(ttl) * time.Second)
|
t := time.NewTicker(time.Duration(ttl/2) * time.Second)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-t.C:
|
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 {
|
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.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