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)
| 1294 | // |
| 1295 | // ShutdownWithContext does not close keepalive connections so its recommended to set ReadTimeout to something else than 0. |
| 1296 | func (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 |
| 1315 | func (app *App) Server() *fasthttp.Server { |