-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement supervision of processes and services via catch_unwind
#7
Comments
Just some random idea, feel free to ignore if it doesn't fit the project's intended use case!
|
I think that this is out of scope for rabble. External supervisors such as supervisord, upstart, systemd etc.. can already restart the process in case of OOM or segfault. For an infinite loop, I'm not sure how it could even be detected. Isn't this the halting problem? Unfortunately, I think the best way to prevent that is to simply tell users: "Don't do that". For CPU heavy tasks, users can already spawn workers in a separate thread. Lightweight processes are really only useful for IO bound work. Therefore any loops should immediately be suspect. The goal I had in mind for catch_unwind was only to catch rust panics, such as unwraps etc... inside a process or thread so that they could be restarted without restarting the whole OS process. As you have pointed out this isn't ideal, but I think it's the best that can be reasonably achieved with what rust provides today. |
Whoops. Looked like I closed this by accident. |
@z1mvader mentioned he was willing to help with implementing supervision in rabble. I think it's virtually impossible to provide full supervision due to the lack of isolation provided by Rust. However, it is easy to catch panics, and restart any lightweight process or service due to bad I think this can simply be implemented, at least for lightweight processes by wrapping the executor run loop in You should be able to do the same thing for thread based services by wrapping their loop as well: https://github.com/andrewjstone/rabble/blob/master/src/service/service.rs#L51 |
Hmm, Maybe it's not that straightforward. I think in order to figure out which process is crashing in the executor you'd need to wrap this line: https://github.com/andrewjstone/rabble/blob/master/src/executor/executor.rs#L156 You'd need to save the state of the process, prior to running it, and then restore it after crash. I'm not sure what type of perf penalties this would have, in addition to the penalty of calling |
Ok I'll start working on this as soon as possible. I should write to you from here if I have any doubts? |
Yeah, post any issues you have here so that we have a full history for the community. Thanks @z1mvader |
Note, after taking a further look, I'm not sure how doable this is with code as is. Processes and service handlers are not constrained to be |
https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
The text was updated successfully, but these errors were encountered: