Worker Restart Options
Explore Elixir's worker restart options to understand how supervisors manage individual process lifecycles. Learn the differences between permanent, temporary, and transient restart strategies, how to specify them in GenServer modules, and their impact on maintaining stable and reliable applications.
We'll cover the following...
Up till now, we’ve seen how the supervision strategy tells the supervisor to deal with the death of a child process.
There’s a second level of configuration that applies to individual workers. The most commonly used of these is the :restart option.
Previously, we said that a supervisor strategy (such as :one_for_all) is invoked when a worker dies. That’s not strictly true. Instead, the strategy is invoked when a worker needs restarting. And the conditions when a worker should be restarted are dictated by its restart: option:
-
If
:permanent, this ...