-
Notifications
You must be signed in to change notification settings - Fork 117
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
Support graceful shutdown #33
Comments
Please, somehow work on this. I'm building a stateful server and I have to properly shutdown to make data consistent. About the design, I think an easier way is preferred, such as |
I recently came up with another idea: removing the root of evil, By the way, this disables us from spawning something in Drop, but socket close operation should be explicit from my perspective. I'm leaving that discussion separated. |
Has there been any update on this? I'm also working on a server program and it'd be nice to gracefully shut down to the server on some sort of signal. |
@Michael-F-Bryan no there has not been progress on this in this crate, it will likely be closed as "no longer valid" once tokio-rs/tokio-rfcs#3 is implemented |
Would you be able to elaborate on that a bit? Looking at the async/await example on that RFC it sounds like the user is given control, and therefore able to stop a server whenever they want, compared to the current model where a reactor is in charge and all we can do is schedule callbacks... Did I understand that correctly? |
The main thrust of the RFC is to separate out the executor from the reactor itself, and the executor separated out has methods of being shut down and gracefully waiting for shutdown. In general each application has its own definition of graceful shutdown, so it would then be up to you to define the future for shutting down a server. |
Right now there's no way to gracefully shut down a
Core
. There's no API for learning how many tasks are still running or receiving a notification when they're all done. Some more discussion can be found on #16.The current proposal is to add some form of future which receives a notification when there are no tasks on the event loop any more. This would allow building up a "graceful shutdown". My personal preference would be:
This function would return
Ready
if the core has 0 tasks running on it, orNotReady
if there are tasks running. IfNotReady
is returned, then the current task is scheduled to receive a notification when there are 0 tasks running.The text was updated successfully, but these errors were encountered: