[erlang-questions] Gen supervisor query...
Edwin Fine
erlang-questions_efine@REDACTED
Mon Sep 22 14:26:24 CEST 2008
On Mon, Sep 22, 2008 at 8:10 AM, <Dana.RUBINO@REDACTED> wrote:
> Hi Edwin,
>
> Thanks for the advice!
>
You're welcome.
>
> I think you may be correct in that it appears the second process is dying
> shortly after being started - the log is indicating it is being started!
> (they don't register themselves)
>
>
Well, is it possible that they are both contending for the same resource (a
socket?) and the first process to get it wins? Did you try starting SASL?
> Slightly off-topic, any ideas why the appmon uses such a large amount of
> memory when switching to sup view from proc?
>
Sorry, no idea.
>
> Many thanks,
> Dan
>
> ------------------------------
> *From:* emofine@REDACTED [mailto:emofine@REDACTED] *On Behalf Of *Edwin
> Fine
> *Sent:* 22 September 2008 12:27
> *To:* RUBINO, Dana, GBM
> *Cc:* erlang-questions@REDACTED
> *Subject:* Re: [erlang-questions] Gen supervisor query...
>
> Hi Dan
>
> The first thing that comes to mind is, does the generic_tcp_server register
> itself? If so, the second one will fail to start. Do you see any error
> messages? I find if you start SASL before you run your program, you may get
> better error information (application:start(sasl), or -boot sasl on the
> command line). Anotyher possibility is, could one of them have died before
> you looked in appmon? What does your output/error log look like?
>
> The other thing is, instead of explicitly looking in registered() for your
> connection monitor, you coud just use whereis():
>
> case whereis(?CONNCOUNTER) of
> undefined -> % Not registered
> register(?CONNCOUNTER, spawn(fun() -> counter(0, MaxConnections)
> end)),
> error_logger:info_msg("TCP server <~p> started TCP connection
> monitor.~n", [self()]);
> Pid ->
> error_logger:info_msg(
> "TCP connection monitor (~p) already registered as ~p
> ...SKIPPING~n",
> [?CONNCOUNTER, Pid]
> )
> end
>
> Hope this helps.
>
> 2008/9/22 <Dana.RUBINO@REDACTED>
>
>> Hi all,
>>
>> I have a simple supervisor setup which is watching two worker processes.
>>
>> Now I have created the init method as such:
>>
>>
>> init(Args) ->
>>
>> [{port,Port},{maxconns, MaxConnections},{sockethandlermod,
>> SocketHandlerMod}] = Args,
>>
>> Registered = registered(),
>>
>> case lists:any(fun(X) -> X =:= ?CONNCOUNTER end, Registered) of
>>
>> true ->
>>
>> error_logger:info_msg("TCP connection monitor (~p) already
>> registered...SKIPPING~n",[?CONNCOUNTER]);
>>
>> false ->
>>
>> register(?CONNCOUNTER, spawn(fun() -> counter(0,
>> MaxConnections) end)),
>>
>> error_logger:info_msg("TCP server <~p> started TCP connection
>> monitor.~n", [self()])
>>
>> end,
>>
>>
>>
>> GenTcpServer1 =
>> {'GenTcpServer1',{generic_tcp_server,start_link,[Port,SocketHandlerMod]},
>> permanent,2000,worker,[generic_tcp_server]},
>>
>> GenTcpServer2 =
>> {'GenTcpServer2',{generic_tcp_server,start_link,[Port,SocketHandlerMod]},
>> permanent,2000,worker,[generic_tcp_server]},
>>
>> {ok,{{one_for_one,0,1}, [GenTcpServer1, GenTcpServer2]}}.
>>
>> N
>> othing fancy going on there - I would expect this supervisor to start both GenTcpServer1 AND GenTcpServer2 given two speca have been returned?
>>
>> For some reason it is only starting one when I look in appmon etc.
>>
>> Any thoughts?
>>
>> Many Thanks,
>> Dan
>>
>>
>>
>> ***********************************************************************************
>> The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
>> Authorised and regulated by the Financial Services Authority
>>
>> This e-mail message is confidential and for use by the
>> addressee only. If the message is received by anyone other
>> than the addressee, please return the message to the sender
>> by replying to it and then delete the message from your
>> computer. Internet e-mails are not necessarily secure. The
>> Royal Bank of Scotland plc does not accept responsibility for
>> changes made to this message after it was sent.
>>
>> Whilst all reasonable care has been taken to avoid the
>> transmission of viruses, it is the responsibility of the recipient to
>> ensure that the onward transmission, opening or use of this
>> message and any attachments will not adversely affect its
>> systems or data. No responsibility is accepted by The
>> Royal Bank of Scotland plc in this regard and the recipient should carry
>> out such virus and other checks as it considers appropriate.
>> Visit our websites at: www.rbs.comwww.rbs.com/gbmwww.rbsgc.com
>> ***********************************************************************************
>>
>>
>> _______________________________________________
>> 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/20080922/bf07a376/attachment.htm>
More information about the erlang-questions
mailing list