[erlang-questions] questions about supervisor behavior

Alain O'Dea alain.odea@REDACTED
Mon Dec 27 19:28:03 CET 2010


Some correction.  You should use supervisor:start_child/2 and not gen_server:start_link/4 for this particular case.

Erlang and OTP in Action (http://manning.com/logan) has a very good example of this in sc_element_sup:start_child/2 as seen at https://github.com/erlware/Erlang-and-OTP-in-Action-Source/blob/master/chapter_07/simple_cache/src/sc_element_sup.erl



On 2010-12-27, at 12:42, Seven Du <dujinfang@REDACTED> wrote:

> Thank you all. It works for me. I feel so stupid after I tried all
> options but start_link. In my real code the function actually called
> start_link but I called gen_server:start() in it.
> 
> Thanks again.
> 
> On Mon, Dec 27, 2010 at 11:55 PM, Fernando Benavides
> <fernando.benavides@REDACTED> wrote:
>> I think your problem is that you're not linking the workers to the
>> supervisor.  Remember the supervisor documentation:
>> 
>> The start function must create and link to the child process, and should
>> return {ok,Child} or {ok,Child,Info} where Child is the pid of the child
>> process and Info an arbitrary term which is ignored by the supervisor.
>> 
>> You can try using gen_server:start_link/4 (i.e.
>> gen_server:start_link({local, Name}, ?MODULE, [], []).) instead of
>> gen_server:start/4
>> 
>> Hope this helps :)
>> 
>> On Mon, 2010-12-27 at 23:42 +0800, Seven Du wrote:
>> 
>> Hi all,
>> 
>> I have problems on get the supervisor working.
>> 
>> I want to start a supvisor with 3 children, and then dynamically add
>> children. Everything works fine except that when a child crashes, the
>> supervisor doesn't know and then cannot restart automatically. What
>> I'm doing wrong?
>> 
>> Code in the following link.
>> 
>> https://gist.github.com/756214
>> 
>> Thanks.
>> Seven.
>> 
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>> 
>> 
> 
> 
> 
> -- 
> About: http://about.me/dujinfang
> Blog: http://www.dujinfang.com
> Proj:  http://www.freeswitch.org.cn
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 


More information about the erlang-questions mailing list