[erlang-questions] Pass Name to Dynamic Supervisors

Samuel Elliott <>
Thu Sep 8 10:44:34 CEST 2011


I managed this when writing an OS erlang app recently.

in the supervisor:
https://github.com/lenary/ironmaster/blob/master/src/im_provider_sup.erl#L38-40
and in the worker:
https://github.com/lenary/ironmaster/blob/master/src/im_provider.erl#L56-62

Essentially, the supervisor's `start_child/1` takes the callback module, and
adds a childspec to the supervisor. This childspec then calls down into the
worker's `start_link/1` which takes the same callback module name as an
argument, and starts a gen_server using itself. Yes, it sounds complicated,
but it's not really.

Sam

On Thu, Sep 8, 2011 at 3:09 AM, Christopher Wilson <>wrote:

> Is there a way to pass a name/ID into the call to supervisor:start_child,
> more specifically to init()?  I'd like to specify the name of the worker or
> supervisor such that when I ran supervisor:which_children I could identify
> what's what.
>
> Also, I've tried [unsuccessfully] to dynamically create a child spec and
> add pass that in.  Are there any decent examples out there on how to do this
> outside of the man pages?
>
> Thank you.
>
> -Chris
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
Samuel Elliott

http://lenary.co.uk/
+44 (0)7891 993 664
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110908/215048f1/attachment.html>


More information about the erlang-questions mailing list