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

Update graceful shutdown example #2355

Merged
merged 3 commits into from
Nov 26, 2023
Merged

Update graceful shutdown example #2355

merged 3 commits into from
Nov 26, 2023

Conversation

davidpdrsn
Copy link
Member

Fixes #2352

Was a bit more work than I expected because hyper-util doesn't seem to support graceful shutdown yet.

@seanmonstar is this how you'd recommend doing graceful shutdown?

examples/graceful-shutdown/src/main.rs Outdated Show resolved Hide resolved
examples/graceful-shutdown/src/main.rs Show resolved Hide resolved

// Wait for all tasks to complete.
debug!("waiting for {} tasks to finish", close_tx.receiver_count());
close_tx.closed().await;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, didn't know one could await the closing of all watch channel receivers.

davidpdrsn and others added 2 commits November 26, 2023 11:28
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
@davidpdrsn davidpdrsn enabled auto-merge (squash) November 26, 2023 10:31
@davidpdrsn davidpdrsn merged commit da82e88 into main Nov 26, 2023
18 checks passed
@davidpdrsn davidpdrsn deleted the david/graceful-shutdown branch November 26, 2023 10:34
@detro
Copy link

detro commented Nov 27, 2023

Thanks for fixing the example.

But I must say, the absence of a Server that offered a .with_graceful_shutdown makes of a much more verbose version of this behaviour.

I hope something will be offered soon-ish, as I don't see any prod-worthy system going out without a graceful shutdown, and having to provide all that code I see in the example now, seems wasteful and repetitive (community wise).

@davidpdrsn
Copy link
Member Author

@detro Yeah it leaves a lot to be desired, though I don't think it should deter anyone from updating but that's of course up to you.

I encourage you to help contributing to hyper-util. That way everyone benefits! The issue regarding graceful shutdown is here. Since wrapping up axum 0.7 I have started contributing myself and will continue to do so.

@sunsided
Copy link

sunsided commented Dec 6, 2023

Also related: hyperium/hyper-util#66.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update axum's graceful shutdown example
4 participants