@@ -165,7 +165,8 @@ defmodule Supervisor do
165
165
means that, if the child process exits due to a `:normal`, `:shutdown`
166
166
or `{:shutdown, term}` reason, it won't be restarted. This is useful
167
167
as it allows our workers to politely shutdown and be removed from the
168
- simple one for one supervisor, without being restarted
168
+ simple one for one supervisor, without being restarted. You can find
169
+ more information about restart strategies on `Supervisor.Spec`
169
170
170
171
With the supervisor defined, let's dynamically start stacks:
171
172
@@ -180,6 +181,26 @@ defmodule Supervisor do
180
181
Supervisor.count_children(sup_pid)
181
182
#=> %{active: 2, specs: 1, supervisors: 0, workers: 2}
182
183
184
+ ## Exit reasons
185
+
186
+ From the example above, you may have noticed that the transient restart
187
+ strategy for the worker does not restart the child in case it crashes with
188
+ reason `:normal`, `:shutdown` or `{:shutdown, term}`.
189
+
190
+ So one may ask: which exit reason should I choose when existing my worker?
191
+ There are three options:
192
+
193
+ * `:normal` - on such cases, the exit won't be logged, there is no restart
194
+ on transient mode and linked processes are not broken
195
+
196
+ * `:shutdown` or `{:shutdown, term}` - on such cases, the exit won't be
197
+ logged, there is no restart on transient mode and linked processes are
198
+ broken (with the same exit reason)
199
+
200
+ * any other term - on such cases, the exit will be logged, there are
201
+ restarts on transient mode and linked processes are broken (with the
202
+ same exit reason)
203
+
183
204
## Name Registration
184
205
185
206
A supervisor is bound to the same name registration rules as a `GenServer`.
0 commit comments