So I'm working on a small server for local web development (live-reloading, etc.), and I'd like to prevent, that the server crashes.
Currently, I have a "supervisor" that executes the components (HTTP server, WebSocket server, etc), and restarts them when they fail.
This supervisor made it a bit more difficult to implement my web dev server (for example, because I have mutable data that now has to be behind a Mutex). Also, as far as I see, my (pretty naive) implementation of the supervisor could lead to problems (currently I just re-start the component, for example. And I'm using the
Mutex type from
parking_lot, but I'm not 100% sure what could happen if a component with mutable data crashes while altering the data).
Everything is working pretty well. However, I'm not 100% sure anymore if a supervisor makes much sense in this context.
If I remember correctly, there was only one instance when a component
panic!ked so far (and that was during the implementation, not even when everything was working).
So I'm wondering: If I do proper error handling (no
unwrap, etc.) – does it even make sense here to implement a supervisor?
I'd hate it, if, let's say, the HTTP server panics, which would result in nothing working anymore.
Maybe the right way would be, to still have a "supervisor", but instead of blindly restarting a failed component, to just stop all other components, to fail gracefully.
What do you think?