Configuring the Application
Let's learn how to start child processes and make them supervised.
We'll cover the following...
We'll cover the following...
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:
Press + to interact
def start(_type, _args) dochildren = [{ 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: