[erlang-questions] Supervisor on-demand

t ty <>
Mon Feb 25 17:08:52 CET 2008


Have a look at http://erlang.org/doc/design_principles/part_frame.html

section 5.9 Simple-One-For-One Supervisors for details.

Regards

t

2008/2/25 Juan Jose Comellas <>:
> Don't I have to call supervisor:start_link() before issuing a start_child()?
> What would I return from the Module:init() callback that is called from
> supervisor:start_link()? Right now this is what this function looks like:
>
> init([Provider, Host, Port, Password]) ->
>     {{one_for_one, 1, 60},
>      [{Provider, {fs_provider, start_link, [provider_name(Provider), Host,
> Port, Password]},
>        transient, 15, worker, [fs_provider]}]}.
>
> I tried calling supervisor:start_link() at the beginning of my program and
> returning 'ignore' from the Module:init() callback but the supervisor would
> not start.
>
>
>
>
>
> On 2/25/08, Andreas Hillqvist <> wrote:
> > Hi.
> >
> > It sounds like simple_one_for_one would work for you.
> > It is possible to pass the id or any additional parameters to start_child:
> >    supervisor:start_child(SupRef, [YourId])
> >
> >
> > Regards
> > Andreas Hillqvist
> >
> > 2008/2/25, Juan Jose Comellas <>:
> >
> > > I have the following scenario and I'm not really sure of how to
> represent it
> > > with OTP. I have an application (appmod) running within Yaws that has to
> > > create a worker process every time it receives an HTTP request.The
> worker
> > > process is created for a specific ID that comes with the request and for
> > > different requests that contain the same ID, the same worker process
> must be
> > > used. Once instantiated, the worker process must remain up and until it
> is
> > > explicitly stopped.
> > >
> > > I want to monitor the worker processes with an OTP supervisor, but so
> far
> > > I'm not completely sure of what the correct approach should be. Should I
> > > call supervisor:start_link() the first time I get a request for a
> specific
> > > ID and then supervisor:start_child() for the following ones? Or should I
> > > just create one supervisor process per worker process I have? Can anyone
> > > share some tips with me on how to design a solution for this problem
> within
> > > OTP?
> > >
> > > Thanks.
> > >
> > >
> >
> > > _______________________________________________
> > > erlang-questions mailing list
> > > 
> > > http://www.erlang.org/mailman/listinfo/erlang-questions
> > >
> >
>
>
> _______________________________________________
>  erlang-questions mailing list
>  
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list