[erlang-questions] supervisor does not restart my worker

Matej Kosik kosik@REDACTED
Sat Jun 9 13:38:39 CEST 2007


Hi,

While playing with Erlang, I have tried to check supervisor behavior. I have written a simple generic server (it is attached as `serv.erl' file) that is started by a simple supervisor (its source is in the attached `sup.erl' file).

The API of the server is simple:

	serv:question()
	serv:fail()

The second service intentionally fails. I wanted to see how the generic server is restarted so that I could continue using it (those services that does not cause failure). However, the `serv' worker is not restarted. What am I doing wrong?


<DETAILS>
I start supervisor as follows

	1> sup:start_link().

Then I try to use services of my server:

	2> serv:question().
	42
	3> serv:question().
	42

But when I call the service that causes failure of the server

	4> serv:fail().

I get

	=ERROR REPORT==== 9-Jun-2007::13:34:51 ===
	** Generic server serv terminating
	** Last message in was fail
	** When Server state == []
	** Reason for termination ==
	** {{badmatch,2},[{serv,handle_call,3},{proc_lib,init_p,5}]}
	** exited: {{{badmatch,2},[{serv,handle_call,3},{proc_lib,init_p,5}]},
            {gen_server,call,[serv,fail]}} **
	5>
	=ERROR REPORT==== 9-Jun-2007::13:34:51 ===
	** Generic server <0.32.0> terminating
	** Last message in was {'EXIT',<0.30.0>,
                               {{{badmatch,2},
                                 [{serv,handle_call,3},{proc_lib,init_p,5}]},
                                {gen_server,call,[serv,fail]}}}
	** When Server state == {state,{<0.32.0>,sup},
                               one_for_all,
                               [{child,
                                    <0.37.0>,
                                    serv,
                                    {serv,start_link,[]},
                                    permanent,
                                    2000,
                                    worker,
                                    [serv]}],
                               {dict,0,
                                     16,
                                     16,
                                     8,
                                     80,
                                     48,
                                     {[],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      [],
                                      []},
                                     {{[],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       [],
                                       []}}},
                               20,
                               3600,
                               [{1181,388891,757484}],
                               sup,
                               []}
	** Reason for termination ==
	** {{{badmatch,2},[{serv,handle_call,3},{proc_lib,init_p,5}]},
	    {gen_server,call,[serv,fail]}}

and no restart happens.
</DETAILS>

Thanks for any clues.
Cheers
-- 
Matej Kosik
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: serv.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070609/b247cb14/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sup.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070609/b247cb14/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070609/b247cb14/attachment-0002.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070609/b247cb14/attachment.bin>


More information about the erlang-questions mailing list