Erlang / Erlang Advanced Interview questions
Explain the execution flow of application:start/1 and its dependency resolution?
Calling application:start(my_app) doesn't just run one function — it triggers a
dependency-aware startup sequence managed by the application controller.
flowchart TD
A[application:start my_app] --> B{Dependencies in .app already running?}
B -->|No| C[Start each missing dependency first, recursively]
C --> B
B -->|Yes| D[Call my_app:start/2 - the mod callback]
D --> E[Top-level supervisor starts via start_link]
E --> F[Supervisor starts its children per its init/1 spec]
The application controller reads the applications list from the .app file and
recursively ensures each dependency is already running, starting any that aren't, before calling the target
application's own start callback. That callback (matching the mod entry) is expected to start and
return the PID of a top-level supervisor, which then boots its own children exactly as any supervision tree
does. If a required dependency can't be started, the whole start call fails rather than leaving the application
half-initialized.
More Related questions...