How to define umbrella apps startup order

I’m working on an application with 4 umbrella apps inside of it. One of the apps is a Phoenix App that is used as API to serve the data, the others are some big dependencies that turned into apps.

So, the problem is with two of these dependencies (umbrella apps). One of them, let’s call it: A, uses a GenStage consumer that sends/fetch some data to another dependency, in our example, we will call it B.

For some reason that I can’t find out, the module B.Repo isn’t started when the A consumer makes a call to B (to save/fetch the data).

** (RuntimeError) could not lookup Ecto repo B.Repo because it was not started or it does not exist

If I make a Process.sleep call to make the consumer wait, it works properly.

Is there any way that I can choose the order that the umbrella apps starts? So that B starts before A and so it’s already available when requested?

How are you deploying/starting the applications? Are these umbrella applications just library dependencies or are they full blown releases that get deployed separately?

If these are just library dependencies, are you adding them to your main applications dependency list? Because that should be enough to start the applications in order (meaning that all dependencies and transitive dependencies will start before your main application).

If these are full blown releases with separate deployments, the answer changes to “it depends”. But without knowing how you have setup your deployments, I don’t think we can really offer suggestions here.

2 Likes

How are you deploying/starting the applications? Are these umbrella applications just library dependencies or are they full blown releases that get deployed separately?

They are not deployed separately, they all go together in the same mix release command.

If these are just library dependencies, are you adding them to your main applications dependency list? Because that should be enough to start the applications in order (meaning that all dependencies and transitive dependencies will start before your main application).

Yes they were being added to the dependency list (or at least, should be). I just figured out that in this specific case our dependency B wasn’t on A’s dependency list. Added it and the problem is solved. Didn’t know that the dependencies were started before the main application

Thank you for the help