Search⌘ K
AI Features

Configuring the Application

Explore how to configure the application module in Elixir to automatically start supervised child processes using OTP. Understand child specifications, process lifecycle management, and failover control within a supervisor for building robust Elixir systems.

The next step is to tell application.ex to automatically use the QuizManager.start_link/3 we just wrote to start a child process.

Starting a child process

In /lib/mastery/application.ex, we’ll add the following to the list of child processes, like this:

C++
def start(_type, _args) do
children = [
{ Mastery.Boundary.QuizManager,
[name: Mastery.Boundary.QuizManager] }
]

We’ve told OTP that this application should have a generic supervisor. The following code tells the Supervisor how to get a child specification for this process:

{ Mastery.Boundary.QuizManager, 
[name: Mastery.Boundary.QuizManager] 

Remember, a child specification defines the following:

  • A supervisor’s lifecycle policies.

  • The rules that govern when and how to start and stop a given process.

Our code will do this: ...