Jesse Shieh
Jesse Shieh

Reputation: 4850

In Elixir, are dependent applications supervised?

So far, I know that when I start my Elixir application, a bunch of dependent applications also get started.

Are these dependent applications started inside my app supervision tree somehow?

What happens if a dependent application crashes? Is it restarted?

Upvotes: 4

Views: 556

Answers (2)

Pascal
Pascal

Reputation: 14042

I guess that Elixir works like Erlang for application.

  • In Erlang each application have an independent supervision tree
  • If an application crashes, this means that the topmost supervisor did crash, and that all the restart strategy failed. There is few chance that simply adding a new layer of supervision will solve the problem.
  • it is possible to start all the dependencies using application:ensure_all_started(Application[,StartType]), StartType can be either
    • temporary : (default value): nothing occurs if a temporary application stops for any reason
    • permanent : all other applications terminate if a permanent application stops for any reason
    • transient : all other applications terminate is a transient application stops for any reason but normal
  • it is also possible to call application:ensure_started(Application[,StartType]) for each dependencies. Note that in both cases, the StartType only controls the effect of one application termination on the others, but there is no restart strategy applied.
  • it is possible to know which applications are running using application:which_applications()

Upvotes: 5

Pouriya
Pouriya

Reputation: 1626

In Erlang VM all applications start as children application_master.
Every application has StartType which can be one of temporary, transient and permanent.
A permanent and in some cases transient application crash will affect on entire Erlang VM (VM will crash and crash.dump file will created).
According to the Elixir application module you can set type of your dependencies in start/2.

Upvotes: 0

Related Questions