1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00

fix registry TTL. (#1537)

* fix registry.
1. When etcd stops, the application cannot stop.
2. Stop consul first, then stop app. Then start consul, the registered service remains in consul registry as an unhealthy status.

Co-authored-by: corel <corelchen@qq.com>
This commit is contained in:
aiscrm
2021-10-11 13:46:07 +08:00
committed by GitHub
parent 69fc5cca87
commit 9743ad8d32
2 changed files with 9 additions and 6 deletions
+1
View File
@@ -117,6 +117,7 @@ func (a *App) Run() error {
err := a.Stop()
if err != nil {
a.opts.logger.Errorf("failed to stop app: %v", err)
return err
}
}
}
+8 -6
View File
@@ -90,17 +90,19 @@ func (d *Client) Register(ctx context.Context, svc *registry.ServiceInstance, en
Port: int(port),
Checks: []*api.AgentServiceCheck{
{
CheckID: "service:" + svc.ID,
TTL: "50s",
Status: "passing",
CheckID: "service:" + svc.ID,
TTL: "30s",
Status: "passing",
DeregisterCriticalServiceAfter: "90s",
},
},
}
if enableHealthCheck {
asr.Checks = append(asr.Checks, &api.AgentServiceCheck{
TCP: fmt.Sprintf("%s:%d", addr, port),
Interval: "20s",
Status: "passing",
TCP: fmt.Sprintf("%s:%d", addr, port),
Interval: "20s",
Status: "passing",
DeregisterCriticalServiceAfter: "90s",
})
}
err := d.cli.Agent().ServiceRegister(asr)