[erlang-questions] supervisor children's pid
Vance Shipley
vances@REDACTED
Wed May 18 13:53:59 CEST 2011
On Wed, May 18, 2011 at 09:44:59AM +0000, Robert Virding wrote:
} After the supervisor has started a child server won't it then
} be running completely unsynchronised with the supervisor?
The supervisor starts each child specification in the order provided.
Sure, the first child started is up and running on his own before the
next ones however in my example the child then calls the supervisor
to learn all the child specifications. The supervisor won't answer
until the last child is started. In my example the supervisor will
have queued requests from the other children when it is finished
starting the last child.
Try adding a delay in the initialization and you'll see the same result:
init([Sup, N]) ->
receive after 4000 -> ok end,
{ok, #state{sup = Sup, state = init, n = N}, 0}.
1> supervisor:start_link(which_sup, []).
Server=1, Siblings=[<0.39.0>,<0.38.0>]
Server=2, Siblings=[<0.39.0>,<0.37.0>]
Server=3, Siblings=[<0.38.0>,<0.37.0>]
{ok,<0.36.0>}
} In that case how will a server know that all the other servers have
} been started?
When their request is handled all initialization is complete.
--
-Vance
More information about the erlang-questions
mailing list