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

Method ShutdownWithContext

app.go:1296–1312  ·  view source on GitHub ↗

ShutdownWithContext shuts down the server including by force if the context's deadline is exceeded. Make sure the program doesn't exit and waits instead for ShutdownWithTimeout to return. ShutdownWithContext does not close keepalive connections so its recommended to set ReadTimeout to something el

(ctx context.Context)

Source from the content-addressed store, hash-verified

1294//
1295// ShutdownWithContext does not close keepalive connections so its recommended to set ReadTimeout to something else than 0.
1296func (app *App) ShutdownWithContext(ctx context.Context) error {
1297 app.mutex.Lock()
1298 defer app.mutex.Unlock()
1299
1300 var err error
1301
1302 if app.server == nil {
1303 return ErrNotRunning
1304 }
1305
1306 // Execute the Shutdown hook
1307 app.hooks.executeOnPreShutdownHooks()
1308 defer app.hooks.executeOnPostShutdownHooks(err)
1309
1310 err = app.server.ShutdownWithContext(ctx)
1311 return err
1312}
1313
1314// Server returns the underlying fasthttp server
1315func (app *App) Server() *fasthttp.Server {

Callers 3

ShutdownMethod · 0.95
ShutdownWithTimeoutMethod · 0.95

Calls 4

LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1