Skip to content
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 Shutdown of Server #1869

Closed
theduke opened this issue Dec 28, 2022 · 5 comments
Closed

Graceful Shutdown of Server #1869

theduke opened this issue Dec 28, 2022 · 5 comments

Comments

@theduke
Copy link

theduke commented Dec 28, 2022

Am I missing a way to do orderly shutdown of the server?

As in: a way to stop the server from accepting new connections, finish the running requests and then resolve the ServerFuture.?

@djc
Copy link
Collaborator

djc commented Dec 30, 2022

Yup, it looks like there's currently no way to do that. Would you be able to submit a PR to fix that?

@bluejekyll
Copy link
Member

Yeah, this hasn't been implemented yet. I've had an old issue from the beginning of the project to implement something else for this as well for doing a config reload on a SIGHUP, #20.

I think this issue could be good for library support, while the SIGHUP would be specific to the trust-dns binary. The way I see it is we need a couple of things to be implemented. Internally the server needs to have a shared atomic for triggering the safe shutdown. This would then be wired into all the loops on all the listening sockets to shut down those listeners. The challenge that we'd need a good solution for is to make sure those listening loops are woken even if no new connections come in. I don't know how else to trigger that. There may be some features in Tokio or Futures that I'm unfamiliar with that make that easy.

@djc
Copy link
Collaborator

djc commented Dec 30, 2022

Could probably do a tokio::select!() against the listener on one side and a sync primitive like a tokio::sync::Notify on the other side?

@bluejekyll
Copy link
Member

Yes; Notify is probably a good option to do that.

@yerke
Copy link

yerke commented Aug 9, 2023

I think this issue was solved in #1977

@djc djc closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants