Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[feat] - Graceful shutdown - Hosting Services & clean exit #20

Open
MrDwarf7 opened this issue Jan 7, 2025 · 2 comments · May be fixed by #21
Open

[feat] - Graceful shutdown - Hosting Services & clean exit #20

MrDwarf7 opened this issue Jan 7, 2025 · 2 comments · May be fixed by #21

Comments

@MrDwarf7
Copy link

MrDwarf7 commented Jan 7, 2025

Description

Currently, when shutting down the main server loop, the vectored launcher/custom join_all which is called in
main->crate::util::tasks::join_all() does not properly/fully exit upon SIGINT/SIGTERM.

This results in a partial or “hung” shutdown state that never actually completes.
Implementing a graceful shutdown handler will ensure the primary server loop and all the child services quit cleanly once the shutdown future completes.

This is the recommended approach by Axum/Tokio for shutdowns from what I understand.
If there's a reason I've missed (Perhaps something to do with the Messenger) then please clarify for me so I can understand the intention.

Why It’s Needed

Provides a more reliable and consistent shutdown flow.
Prevents lingering resources or partial states when stopping the application.
Aligns behavior with best practices for asynchronous service shutdown.

Proposed Fix

Add a graceful shutdown handler that triggers on service stop signals (e.g., SIGINT, SIGTERM).
Update the vectored launcher to correctly exit after the shutdown future completes.

Acceptance Criteria

Server resources/clients stop and release resources properly when a shutdown signal is triggered.
Vectored launcher cleanly terminates without leaving any dangling tasks
No observable hangs or partial shutdown states.

A pull request (PR) referencing this issue will be opened shortly to implement the above changes.

@MrDwarf7 MrDwarf7 linked a pull request Jan 7, 2025 that will close this issue
@robatipoor
Copy link
Owner

Thank you! I will review the code as soon as possible.

@MrDwarf7
Copy link
Author

Any feedback is more than welcome so; please, feel free to mention or recommend anything at all, always hungry to learn something. (and there's something to learn from everyone!)

Also thank-you too, for creating it - I found it a great starting point to model off of. Hoping changes like these add some extra value for others that may be in a similar situation as I was when I discovering it 😄

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

Successfully merging a pull request may close this issue.

2 participants