[erlang-questions] Supervisor on-demand

Juan Jose Comellas juanjo@REDACTED
Mon Feb 25 16:54:39 CET 2008


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 <andreas.hillqvist@REDACTED> 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 <juanjo@REDACTED>:
>
> > 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.Theworker
> > 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
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080225/8162e553/attachment.htm>


More information about the erlang-questions mailing list