[erlang-questions] supervisor children's pid
Robert Virding
robert.virding@REDACTED
Wed May 18 11:44:59 CEST 2011
After the supervisor has started a child server won't it then be running completely unsynchronised with the supervisor? In that case how will a server know that all the other servers have been started?
Robert
----- "Vance Shipley" <vances@REDACTED> wrote:
> On Wed, May 18, 2011 at 12:37:02AM +0200, Roberto Ostinelli wrote:
> } currently, i'm calling supervisor:which_children/1 on the init
> function of
> } the gen_servers, and match the Ids to get the Child [Pid].
>
> You can't call the supervisor from the init function of one of it's
> own children. You have to return from init/1 before that is
> possible.
>
> What you can do is to return {ok, State, Timeout} from init/1 with
> a Timeout value of 0 and go on with the initialization after the
> supervisor has completed starting the children. The attached example
> uses a psuedo state to carry on with the initialization:
>
> 1> supervisor:start_link(which_sup, []).
> Server=1, Siblings=[<0.36.0>,<0.35.0>]
> Server=2, Siblings=[<0.36.0>,<0.34.0>]
> Server=3, Siblings=[<0.35.0>,<0.34.0>]
> {ok,<0.33.0>}
>
> } is this the best strategy to achieve this?
>
> Yes, use supervisor:which_children/1 to learn the siblings.
>
>
> --
> -Vance
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list