-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graceful doesn't return after calling http.Server.Shutdown() #68
Comments
the go.mod I used to reproduce the bug:
|
Hey, that's a great point! Any ideas you have to implement that are highly appreciated! |
Here are some things that might help:
A more general approach might be to rethink the design of the |
Thank you for these ideas! I think another option would be to use
and then listen to |
I think |
Preflight checklist
Describe the bug
The Graceful function blocks in here if you manually shutdown the server.
This was a surprise to me, since the
http.Server
returned bygraceful.WithDefaults
has a regularShutdown
method that you can call, yet if you do it, thegraceful.Graceful
function still hangs waiting for a signal.Reproducing the bug
This program should exit in 4 seconds, yet it hangs until you send one of the signals used by Graceful.
Relevant log output
; go run main.go 2022/06/09 08:42:44 starting server 2022/06/09 08:42:48 shutting down server ^C2022/06/09 08:42:54 server closed
Note how the last line was not printed just after the second line, I had to press Control-C to finish the program instead.
Relevant configuration
No response
Version
v0.1.2
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Other
Additional Context
When you call
Shutdown
on the server started withgraceful.Graceful
thestart
call here returns with anhttp.ErrServerClosed
, then the execution blocks on line 80 because the goroutine started in line 59 is blocked on line 62 still waiting for a signal to arrive, even though the server is not longer running.Ideally, when starting a server via graceful, we should still be able to shut it down using the standard method (
http.Server.Shutdown
) and theGraceful
function should return without leaking the goroutine started here.The text was updated successfully, but these errors were encountered: