cmd/soroban-rpc: Shutdown HTTP server gracefully using server.Shutdown instead of supporthttp Package - #566
Merged
Merged
Conversation
…tellar/soroban-tools into soroban-http-graceful-shutdown
tamirms
approved these changes
Apr 7, 2023
2opremio
reviewed
Apr 10, 2023
2opremio
reviewed
Apr 10, 2023
tsachiherman
approved these changes
Apr 10, 2023
tsachiherman
left a comment
Contributor
There was a problem hiding this comment.
I like this implementation. I think that it could be further improve shutting down all the other services by passing the context to d.Close().
What I had in mind is a "hard limit" of terminating the service within 5 second or letting it shut down on its own faster. Keep in mind that if we won't persist data or disconnect existing connections - that's perfectly fine.
In case the shutdown takes more than 5 seconds, we should be generating a log entry telling us why this is the case ( i.e. one of the services is hanged.. )
Co-authored-by: Alfonso Acosta <alfonso@stellar.org>
Co-authored-by: Alfonso Acosta <alfonso@stellar.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Currently, we rely on the supporthttp package to finish pending HTTP requests before shutting down. This PR removes that dependency and uses the server.Shutdown method directly, alongside the appropriate OS signal handling.
This PR still uses the same values as before for relevant timeouts:
Open to suggestions on testing this, or if it's even necessary.
Closes #499
Why
Without graceful shutdown, when you kill soroban-rpc it may drop ongoing HTTP requests. We would like to wait a grace period while finishing any outgoing requests and closing any open connections. Additionally, we don't want to rely on external packages for this (like how supporthttp relies on the Graceful package).