Starting children at runtime using dynamic supervisors

We've now seen how we can work with supervisors to recover from errors, which will restart crashed processes according to the configuration we provide. However, so far we have to define the children of a supervisor up front, which will be started right after the supervisor starts. Sometimes this doesn't fit our needs, and we need a way to spawn a new child of a supervisor at runtime. This is where dynamic supervisors become useful.

Elixir Version 1.6 introduced the DynamicSupervisor module. As we've stated, this new module deprecates the :simple_one_for_one strategy of regular supervisors. There were many reasons for this extraction to happen, but two of the main ones are that the :simple_one_for_one ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.