Skip to content

Commit

Permalink
close client and metrics listeners firstly when shutting down etcd
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Jan 20, 2025
1 parent fbb2675 commit 0dcb17d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ func (e *Etcd) Close() {
close(e.stopc)
})

for i := range e.Clients {
if e.Clients[i] != nil {
e.Clients[i].Close()
}
}

for i := range e.metricsListeners {
e.metricsListeners[i].Close()
}

// close client requests with request timeout
timeout := 2 * time.Second
if e.Server != nil {
Expand All @@ -428,16 +438,6 @@ func (e *Etcd) Close() {
sctx.cancel()
}

for i := range e.Clients {
if e.Clients[i] != nil {
e.Clients[i].Close()
}
}

for i := range e.metricsListeners {
e.metricsListeners[i].Close()
}

// shutdown tracing exporter
if e.tracingExporterShutdown != nil {
e.tracingExporterShutdown()
Expand Down

0 comments on commit 0dcb17d

Please sign in to comment.