[erlang-questions] Re: supervisors

Siri Hansen erlangsiri@REDACTED
Fri Apr 1 20:28:43 CEST 2011


Hi Wes - you should call a_sup:start_a instead of a_sup:start when trying to
start a2.
Regards
/siri

2011/4/1 Wes James <comptekki@REDACTED>

> Siri,
>
> The same thing happens:
>
> Erlang R14B02 (erts-5.8.3) [source] [smp:2:2] [rq:2] [async-threads:0]
> [hipe] [kernel-poll:false]
>
> Eshell V5.8.3  (abort with ^G)
> 1> make:all([load]).
> Recompile: a_sup
> Recompile: a_sup_2
> up_to_date
> 2> application:start(a).
> a1
> ok
> 3> appmon:start().
> {ok,<0.49.0>}
> 4> a_sup:start(a_sup_2,a2).
> {error,{already_started,<0.46.0>}}
>
> looking at appmon, there is an a_sup process supervising process
> <0.47.0> which I'm guessing is the a_sup_2. What I'm trying to do is
> run a_sup_2 with say name a1, then run a second a_sup_2, with say name
> a2 as if you were running a_sup_2 then then running register("a_sup_2
> process", a1) and then run a second a_sup_2 and get a second <0.xx.0>
> process to do register(<0.xx.0>, a2) and so forth so several a_sup_2's
> can be running but with a different registered name.  Can that be
> done?
>
> thx,
>
> -wes
>
> On Fri, Apr 1, 2011 at 3:48 AM, Siri Hansen <erlangsiri@REDACTED> wrote:
> > Attached you can find my small sample.  Please have a look and let me
> know
> > what differs.
> > Just to add some confusion, my a_sup corresponds to your eapp_sup and my
> > a_sup_2 corresponds to your a_sup.... ;)
> > /siri
> >
> > 2011/3/31 Wes James <comptekki@REDACTED>
> >>
> >> Siri,
> >>
> >> The code is from last weeks training part of the Erlang Factory in San
> >> Francisco.  I don't know if Erlang Solutions would like me sending all
> >> the code to people or not.  I'd send it to you off-list if it was ok
> >> with them.
> >>
> >> Or maybe you could send me a sample of your code to compare with what I
> >> have.
> >>
> >> thx,
> >>
> >> -wes
> >>
> >> On Thu, Mar 31, 2011 at 2:16 AM, Siri Hansen <erlangsiri@REDACTED>
> wrote:
> >> > Hi Wes,
> >> > It should be possible to do exactly what you want. I have tried to
> >> > recreate
> >> > your problem, but I did not succeed. If you want to you may post the
> >> > code
> >> > for the two supervisors and I will have a look at it to see what I'm
> >> > doing
> >> > different.
> >> > Regards
> >> > /siri
> >> >
> >> >
> >> > 2011/3/30 Wes James <comptekki@REDACTED>
> >> >>
> >> >> when I start and app that works fine:
> >> >>
> >> >> =PROGRESS REPORT==== 30-Mar-2011::11:28:05 ===
> >> >>          supervisor: {local,eapp_sup}
> >> >>             started: [{pid,<0.70.0>},
> >> >>                       {name,{a_sup,a1}},
> >> >>                       {mfargs,{a_sup,start_link,[a1]}},
> >> >>                       {restart_type,permanent},
> >> >>                       {shutdown,brutal_kill},
> >> >>                       {child_type,supervisor}]
> >> >>
> >> >> In eapp_sup I have:
> >> >>
> >> >> start_a(Module, Name) ->
> >> >>        supervisor:start_child(?MODULE, child(Module, Name)).
> >> >>
> >> >>
> >> >> child(Module, Name) ->
> >> >>  {{Module, Name}, {Module, start_link, [Name]}, permanent,
> >> >> brutal_kill, supervisor, [Name]}.
> >> >>
> >> >>
> >> >> from starting above it would seem that a_sup has the name a1, but if
> >> >> you run appmon it shows just as a_sup.
> >> >>
> >> >> When I then run
> >> >>
> >> >> eapp:start_a(a_sup,a2).  I would assume that a_sup could load as a
> >> >> second supervisor process with name a2, but this is what I get:
> >> >>
> >> >> eapp_sup:start_a(a_sup,a2).
> >> >> {error,{already_started,<0.70.0>}}
> >> >>
> >> >> I then create a_sup2  and eapp_sup:start_a(a_sup2, a1) and that loads
> >> >> fine, since the module "name" is not the same in the system as a_sup.
> >> >> But it seems like a name should be assigned to these to make them
> >> >> unique by name and be able to use the same supervisor code to
> >> >> supervise some more children.
> >> >>
> >> >> Is that possible?
> >> >>
> >> >> thx,
> >> >>
> >> >> -wes
> >> >> _______________________________________________
> >> >> erlang-questions mailing list
> >> >> erlang-questions@REDACTED
> >> >> http://erlang.org/mailman/listinfo/erlang-questions
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110401/19825d7f/attachment.htm>


More information about the erlang-questions mailing list