fiber icon indicating copy to clipboard operation
fiber copied to clipboard

🚀 [Feature]: Shutdown() add optional timeout

Open pjebs opened this issue 3 years ago • 1 comments

Feature Description

Currently when I call Shutdown(), it seems to wait a long time (many minutes).

It would be good for it to pass in an optional ctx or a max wait time. If it hasn't gracefully shutdown by the max wait time, it hard kills the server connections etc.

Additional Context (optional)

No response

Code Snippet (optional)

No response

Checklist:

  • [X] I agree to follow Fiber's Code of Conduct.
  • [X] I have checked for existing issues that describe my suggestion prior to opening this one.
  • [X] I understand that improperly formatted feature requests may be closed without explanation.

pjebs avatar Sep 14 '22 14:09 pjebs

As different as Shutdown(), we can add ShutdownWithContext(ctx) that checks ctx before graceful shutdowning

efectn avatar Sep 14 '22 14:09 efectn

@li-jin-gou https://github.com/valyala/fasthttp/issues/1389#issuecomment-1267351046

pjebs avatar Oct 04 '22 18:10 pjebs

You can access fasthttp.Server with https://github.com/gofiber/fiber/blob/master/app.go#L852. But it's also OK to me add Close() method to Fiber.

efectn avatar Oct 04 '22 18:10 efectn