[erlang-questions] How to get the start parameter when a gen_fsm exits abnormally?

raocheng <>
Fri Oct 12 08:37:37 CEST 2012

I have created a gen_fsm(module: test_service), which is started as a
temporary child of supervisor(module: test_service_sup).
Since the instance of test_service can be created dynamically, I use the
simple_one_for_one strategy.

However, when the FSM(test_service) exit abnormally, we can not get the
start parameters for the FSM in SUPERVISOR REPORT:
2012-10-12 14:15:28 =SUPERVISOR REPORT====
     Supervisor: {local,test_service_sup}
     Context:    child_terminated
     Reason:     timeout

So it's hard for us to figure out which test_service instance has failed.
 Is there any better method ?

Thanks in advance!

1. If test_service is registered as a  permanent instead of temporary child
of test_service_sup, then when it exits abnormally, the UPERVISOR REPORT
will include its start parameters.

2. This is the code:

start_link(Parameter) ->
gen_fsm:start_link(?MODULE, [Parameter], []).

init([Parameter]) ->
  {ok, trying, state}.

start_child(Parameter) ->
supervisor:start_child(?SERVER, [Parameter]).

init([]) ->
TestServiceSpec = {test_service,
        {test_service, start_link, []},
    {ok, { {simple_one_for_one, 0, 1}, [TestServiceSpec]} }.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121012/dc4cd981/attachment.html>

More information about the erlang-questions mailing list