How to handle application crashes in umbrella projects?

I am thinking of converting my application to an umbrella project in order to separate out individual components better, but have come across an issue regarding application crashes and supervision.

At the moment my application consists of two main components: a database, and a web server (it’s a very basic project for learning purposes).
Each component runs in its own process, supervised by 1 main supervisor. The supervisor is run with the rest_for_one strategy, such that if the database process crashes, the web server is restarted too - since the web server depends on the database.

Now converting the project to an umbrella project, the database and web server would each be in their own applications. From what I can gather, this means that each application would have its own supervisor, and there wouldn’t be any “overall” supervisor for both the applications together.
This strikes me like a problem, because now if the database application crashes, the web server would continue as normal - perhaps causing issues if the web server tries to access the database before it is restarted.

I’m just wondering if a) there is actually an issue here (or if I’m misunderstanding how things work), and if so, b) what would be a decent design approach in order to handle it.

If an otp application crashes the whole beam vm is shutdown. There‘s no restarting at the application level at all. So you don‘t need to worry about your weblayer serving requests, but rather about means of making sure the whole service is restart from the outside.

1 Like