[erlang-questions] start_child() on simple_one_for_one supervisor -> {error, {already_started, ...}} ???

Mark Fine mark.fine@REDACTED
Sun Dec 14 12:53:12 CET 2008


Thanks Nicolas and Dominic!

On Sun, Dec 14, 2008 at 3:19 AM, Nicolas Charpentier <nc@REDACTED> wrote:
> Hi,
>
> mighty wrote:
>> I have a basic simple_one_for_one supervisor that I cannot start
>> multiple children from -- the first call to start_child() works, the
>> second call to start_child() returns
>> {error,{already_started,<0.38.0>}}. My supervisor is
>> simple_one_for_one, so I'd expect to hit the ?is_simple() handling of
>> start_child in supervisor.erl, which should go through
>> supervisor:do_start_child_i() without any fuss, and definitely not
>> return {error, {already_started, ...}} out of
>> supervisor:handle_start_child().
>>
>
> In your case {error, {already_started, _}} is returned by
> gen_server:start_link/4 (and then returned by supervisor:start_child/2.
>
> gen_server:start_link/4 returns an error because you are trying to
> register 2 processes with the same name (my_node).
> Replace the function my_node:start_link/1 with:
>
> start_link(Instance) when is_integer(Instance)->
>      error_logger:info_report([[my_node,start_link,Instance,self()]]),
>      Name = atom_to_list(?MODULE) ++ "_" ++ integer_to_list(Instance),
>      gen_server:start_link({local, list_to_atom(Name)},?MODULE,[],[]).
>
>
>
> Regards,
>
> ----
> Nicolas Charpentier
> http://charpi.net
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list