A Supervisor for the Game
Now that we have the Game module’s child specification showing the values we want, we’re ready to create a custom supervisor. We’ll explore two ways to do this. One is as simple as starting a supervisor process with the right options. The other involves creating a new module that contains the callbacks we’ll need as well as some helper functions we’ll want.
Each game in Islands is a separate GenServer process. These processes will come and go as players start new games and then end them. We’ll need a supervisor specifically to monitor games, and the :simple_one_for_one strategy is perfect for processes that we need to start and stop at runtime.
Most of the work of creating a custom supervisor comes in starting a new ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access