[GH-ISSUE #1869] Graceful Shutdown of Server #802

Closed
opened 2026-03-16 00:18:00 +03:00 by kerem · 5 comments
Owner

Originally created by @theduke on GitHub (Dec 28, 2022).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1869

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.?

Originally created by @theduke on GitHub (Dec 28, 2022). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1869 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`.?
kerem 2026-03-16 00:18:00 +03:00
Author
Owner

@djc commented on GitHub (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?

<!-- gh-comment-id:1367955085 --> @djc commented on GitHub (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?
Author
Owner

@bluejekyll commented on GitHub (Dec 30, 2022):

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.

<!-- gh-comment-id:1368078392 --> @bluejekyll commented on GitHub (Dec 30, 2022): 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.
Author
Owner

@djc commented on GitHub (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?

<!-- gh-comment-id:1368087398 --> @djc commented on GitHub (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?
Author
Owner

@bluejekyll commented on GitHub (Dec 31, 2022):

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

<!-- gh-comment-id:1368152656 --> @bluejekyll commented on GitHub (Dec 31, 2022): Yes; Notify is probably a good option to do that.
Author
Owner

@yerke commented on GitHub (Aug 9, 2023):

I think this issue was solved in https://github.com/bluejekyll/trust-dns/pull/1977

<!-- gh-comment-id:1670591171 --> @yerke commented on GitHub (Aug 9, 2023): I think this issue was solved in https://github.com/bluejekyll/trust-dns/pull/1977
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#802
No description provided.