Alpár Jüttner | 17 Aug 22:33

OTP question

Hi,

I have a fairly basic problem, probably I did a silly mistake. When I
stop an application, it does not terminate the supervisor tree. Please
find an example in the attachment. It is a minimal application with one
supervisor and a server. When I start the application, the supervisor
and the server starts nicely:

        $erl
        Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]
        [async-threads:0] [hipe] [kernel-poll:false]

        Eshell V5.6.3  (abort with ^G)
        1> c(test_ser).
        {ok,test_ser}
        2> c(test_sup).
        {ok,test_sup}
        3> c(test_app).
        {ok,test_app}
        4> application:start(test_app).
        TEST APP START.
        TEST SUPERVISOR START LINK.
        TEST SUPERVISOR INIT.
        TEST SERVER START LINK.
        TEST SERVER INIT.
        ok

But when I stop it, test_app:stop/1 is executed, but
test_sup:terminate/1 and test_server:terminate/2 are not.

(Continue reading)

Edwin Fine | 17 Aug 23:34

Re: OTP question

In test_ser.erl, trap exits:

init([]) ->
    erlang:process_flag(trap_exit, true),
    io:format("TEST SERVER INIT.~n",[]),
    {ok, []}.

Hope this helps,
Edwin

2008/8/17 Alpár Jüttner <alpar <at> cs.elte.hu>
Hi,

I have a fairly basic problem, probably I did a silly mistake. When I
stop an application, it does not terminate the supervisor tree. Please
find an example in the attachment. It is a minimal application with one
supervisor and a server. When I start the application, the supervisor
and the server starts nicely:

       $erl
       Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]
       [async-threads:0] [hipe] [kernel-poll:false]

       Eshell V5.6.3  (abort with ^G)
       1> c(test_ser).
       {ok,test_ser}
       2> c(test_sup).
       {ok,test_sup}
       3> c(test_app).
       {ok,test_app}
       4> application:start(test_app).
       TEST APP START.
       TEST SUPERVISOR START LINK.
       TEST SUPERVISOR INIT.
       TEST SERVER START LINK.
       TEST SERVER INIT.
       ok

But when I stop it, test_app:stop/1 is executed, but
test_sup:terminate/1 and test_server:terminate/2 are not.

       5> application:stop(test_app).
       TEST APP STOP.

       =INFO REPORT==== 17-Aug-2008::22:27:49 ===
           application: test_app
           exited: stopped
           type: temporary
       ok
       6>

What do I do wrong?

Best regards,
Alpar


_______________________________________________
erlang-questions mailing list
erlang-questions <at> erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions



--
For every expert there is an equal and opposite expert - Arthur C. Clarke
<div><div dir="ltr">In test_ser.erl, trap exits:<br><br>init([]) -&gt;<br>&nbsp;&nbsp;&nbsp; erlang:process_flag(trap_exit, true),<br>&nbsp;&nbsp;&nbsp; io:format("TEST SERVER INIT.~n",[]),<br>&nbsp;&nbsp;&nbsp; {ok, []}.<br><br>Hope this helps,<br>Edwin<br><br><div class="gmail_quote">2008/8/17 Alp&aacute;r J&uuml;ttner <span dir="ltr">&lt;<a href="mailto:alpar <at> cs.elte.hu">alpar <at> cs.elte.hu</a>&gt;</span><br><blockquote class="gmail_quote">
Hi,<br><br>
I have a fairly basic problem, probably I did a silly mistake. When I<br>
stop an application, it does not terminate the supervisor tree. Please<br>
find an example in the attachment. It is a minimal application with one<br>
supervisor and a server. When I start the application, the supervisor<br>
and the server starts nicely:<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;$erl<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;[async-threads:0] [hipe] [kernel-poll:false]<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;Eshell V5.6.3 &nbsp;(abort with ^G)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;1&gt; c(test_ser).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{ok,test_ser}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;2&gt; c(test_sup).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{ok,test_sup}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;3&gt; c(test_app).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{ok,test_app}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;4&gt; application:start(test_app).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST APP START.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST SUPERVISOR START LINK.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST SUPERVISOR INIT.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST SERVER START LINK.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST SERVER INIT.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ok<br><br>
But when I stop it, test_app:stop/1 is executed, but<br>
test_sup:terminate/1 and test_server:terminate/2 are not.<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;5&gt; application:stop(test_app).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;TEST APP STOP.<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;=INFO REPORT==== 17-Aug-2008::22:27:49 ===<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;application: test_app<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exited: stopped<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;type: temporary<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ok<br>
 &nbsp; &nbsp; &nbsp; &nbsp;6&gt;<br><br>
What do I do wrong?<br><br>
Best regards,<br>
Alpar<br><br><br>_______________________________________________<br>
erlang-questions mailing list<br><a href="mailto:erlang-questions <at> erlang.org">erlang-questions <at> erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
<br><br clear="all"><br>-- <br>For every expert there is an equal and opposite expert - Arthur C. Clarke<br>
</div></div>
Alpár Jüttner | 18 Aug 10:14

Re: OTP question

Hi,

> In test_ser.erl, trap exits:

Many thanks.

Should I set this for the servers only, or the sub-supervisors, too?
What is the reason why this isn't the default setting?

Best regards,
Alpar
> 
> init([]) ->
>     erlang:process_flag(trap_exit, true),
>     io:format("TEST SERVER INIT.~n",[]),
>     {ok, []}.
> 
> Hope this helps,
> Edwin
> 
> 2008/8/17 Alpár Jüttner <alpar <at> cs.elte.hu>
>         Hi,
>         
>         I have a fairly basic problem, probably I did a silly mistake.
>         When I
>         stop an application, it does not terminate the supervisor
>         tree. Please
>         find an example in the attachment. It is a minimal application
>         with one
>         supervisor and a server. When I start the application, the
>         supervisor
>         and the server starts nicely:
>         
>                $erl
>                Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]
>                [async-threads:0] [hipe] [kernel-poll:false]
>         
>                Eshell V5.6.3  (abort with ^G)
>                1> c(test_ser).
>                {ok,test_ser}
>                2> c(test_sup).
>                {ok,test_sup}
>                3> c(test_app).
>                {ok,test_app}
>                4> application:start(test_app).
>                TEST APP START.
>                TEST SUPERVISOR START LINK.
>                TEST SUPERVISOR INIT.
>                TEST SERVER START LINK.
>                TEST SERVER INIT.
>                ok
>         
>         But when I stop it, test_app:stop/1 is executed, but
>         test_sup:terminate/1 and test_server:terminate/2 are not.
>         
>                5> application:stop(test_app).
>                TEST APP STOP.
>         
>                =INFO REPORT==== 17-Aug-2008::22:27:49 ===
>                    application: test_app
>                    exited: stopped
>                    type: temporary
>                ok
>                6>
>         
>         What do I do wrong?
>         
>         Best regards,
>         Alpar
>         
>         
>         _______________________________________________
>         erlang-questions mailing list
>         erlang-questions <at> erlang.org
>         http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 
> 
> -- 
> For every expert there is an equal and opposite expert - Arthur C.
> Clarke
> 

_______________________________________________
erlang-questions mailing list
erlang-questions <at> erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Ladislav Lenart | 18 Aug 10:36

Re: OTP question

Edwin Fine wrote:
> In test_ser.erl, trap exits:
> 
> init([]) ->
> *    erlang:process_flag(trap_exit, true),
> *    io:format("TEST SERVER INIT.~n",[]),
>     {ok, []}.

Hello,

I would like to clarify that both your supervisor and worker terminated
when the application stopped. Only the worker's (gen_server) terminate/2
callback was not called because the termination reason from its parent
(the supervisor) was atom shutdown which is different from atom normal.
Since the worker didn't trap exit signals, it "crashed".

Ladislav Lenart


Gmane