Reputation: 41648
If a supervisor uses the rest_for_one
restart strategy, and a child is added to it using supervisor:start_child
, is the new child considered to be "before" or "after" the existing children?
Or put in another way, if the existing child is A
and the new child is B
, would B
die if A
died, or would A
die if B
died? I presume the former, but the documentation doesn't explicitly state it.
Upvotes: 2
Views: 247
Reputation: 3869
From Erlang Documentation
rest_for_one - if one child process terminates and should be
restarted, the 'rest' of the child processes -- i.e. the child processes after
the terminated child process in the start order -- are terminated. Then the
terminated child process and all child processes after it are restarted.
So if you add a child, it will be restarted if any existing child dies but the new child cannot kill any other existing child, the order here is the start order.
Upvotes: 1