MCPcopy
hub / github.com/gofiber/fiber / ShutdownWithTimeout

Method ShutdownWithTimeout

app.go:1285–1289  ·  view source on GitHub ↗

ShutdownWithTimeout gracefully shuts down the server without interrupting any active connections. However, if the timeout is exceeded, ShutdownWithTimeout will forcefully close any active connections. ShutdownWithTimeout works by first closing all open listeners and then waiting for all connections

(timeout time.Duration)

Source from the content-addressed store, hash-verified

1283//
1284// ShutdownWithTimeout does not close keepalive connections so its recommended to set ReadTimeout to something else than 0.
1285func (app *App) ShutdownWithTimeout(timeout time.Duration) error {
1286 ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
1287 defer cancelFunc()
1288 return app.ShutdownWithContext(ctx)
1289}
1290
1291// ShutdownWithContext shuts down the server including by force if the context's deadline is exceeded.
1292//

Callers 2

gracefulShutdownMethod · 0.95

Calls 1

ShutdownWithContextMethod · 0.95

Tested by 1