-
Notifications
You must be signed in to change notification settings - Fork 203
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
Gracefully shut down tarpc #473
Comments
Hi, thanks for the question! It should be possible. Can you share your code? Do you have a task that accepts new channels, and then you have a separate task executing each channel? If so, basically you'd just want the channel-accepting task to be abortable (might be able to just wrap it in an abortable future), and then there'd be a signal handler that aborts it. I haven't used signal handlers in rust. The CLI book has some instructions for setting up a thread that handles signals: https://rust-cli.github.io/book/in-depth/signals.html |
Thank you for the comment! Actually i used the term "worker" in a different way: the "worker thread" will do some math, file, net and db work, constantly and independently, and another thread (the one with tarpc) that listens for the client requests (simple CLI + tarpc applications on client PCs), and this thread will read the requests from tarpc and it will set some variables used by the "worker thread". I used "abortable" and works perfectly. |
I'm writing a daemon with two threads: a tarpc that gets the client requests, and a "worker".
When i terminate (TERM signal, not KILL), i need that the tarpc shuts down gracefully, simply not accepting further connections but serving the active requests.
Is there a way?
i've read #307 but i could not find a way.
The text was updated successfully, but these errors were encountered: