[erlang-questions] Newbie question--workers starting supervisors
Tue Apr 17 17:18:03 CEST 2007
Yes, I would say it's OTPish to do that. You'd have to have a listener
for these external events, such as a gen server.
You can start new children for your supervisor, which can in turn be
other supervisors. You would do that with a function in your top
supervisor module which calls the start_child(SupRef, ChildSpec)
function in the supervisor module. You can then, from your other
modules call, for example, myTopSupervisor:add_new_sup(), which will
call start child with a supervisors child specification.
On 4/17/07, Edmund Jorgensen <tomheon@REDACTED> wrote:
> Hi Adam,
> Thanks for your reply!
> > If the gen_server is supervised, where's that supervisor? Shouldn't it
> > be in the application then?
> Yes, that supervisor is started by the application.
> > The supervisors will be linked to the gen_server, but you'd have to
> > write any crash-handling etc yourself in the gen_server, e.g. act as a
> > supervisor. That's the only trouble I could think about right now. So
> > the question is, what code do you actually have in that gen_server and
> > why can't it be somewhere else?
> The gen_server is very simply: it just starts new supervisors based on
> external events. The only reason I did it this way was because all
> the examples I had seen of the supervisors had no code in them beyond
> the starting of the original processes they watched. So I guess my
> question becomes this: is it OTPish to put a few extra functions in a
> supervisor model for starting new linked supervisors in response to
> external events? Using simple_one_for_one, I guess? In other words,
> to make that server a supervisor?
> Sorry if this is painfully obvious...I really have done my reading up,
> but it's my first OTP app. :-)
More information about the erlang-questions