MCPcopy Index your code
hub / github.com/labstack/echo / gracefulShutdown

Function gracefulShutdown

server.go:181–200  ·  view source on GitHub ↗
(shutdownCtx stdContext.Context, sc *StartConfig, server *http.Server, logger *slog.Logger)

Source from the content-addressed store, hash-verified

179}
180
181func gracefulShutdown(shutdownCtx stdContext.Context, sc *StartConfig, server *http.Server, logger *slog.Logger) {
182 <-shutdownCtx.Done() // wait until shutdown context is closed.
183 // note: is server if closed by other means this method is still run but is good as no-op
184
185 timeout := sc.GracefulTimeout
186 if timeout == 0 {
187 timeout = 10 * time.Second
188 }
189 waitShutdownCtx, cancel := stdContext.WithTimeout(stdContext.Background(), timeout)
190 defer cancel()
191
192 if err := server.Shutdown(waitShutdownCtx); err != nil {
193 // we end up here when listeners are not shut down within given timeout
194 if sc.OnShutdownError != nil {
195 sc.OnShutdownError(err)
196 return
197 }
198 logger.Error("failed to shut down server within given timeout", "error", err)
199 }
200}

Callers 1

startMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…