Dynamic OTP Children and simple_one_for_one

mark peleus mark.peleus@REDACTED
Mon Oct 19 17:01:14 CEST 2009


Hi,

My OTP application need to create a gen_server for every user when he
connects to the server.
I think the supervisor should be of type simple_one_for_one because all the
children will be instances of the same gen_server.

I don't understand what should be the myapp_sup:init/1 function.
It suppose to return {ok, {SupervisorSpecification, ChildSpecificationList}}
In my case I don't have connected users yet when starting the application so
ChildSpecificationList is empty?

When a user connects to the server I need to create a gen_server for him so
I'll use:
supervisor:start_child(SupervisorName, ChildSpec)
SupervisorName is the pid or the registered supervisor name.
Do I need to explicitly register the supervisor or is it registered
automatically in myapp_sup:init/1 ?

In case of simple_one_for_one ChildSpec should be a list of arguments and
the ChildSpec defined in myapp_sup:init/1 is being used.
If I didn't start a gen_server in the init and just returned an empty list
of Children will it work?
Do I need to create a dummy child for this to work or maybe use one_for_one
instead of simple_one_for_one?

Thanks


More information about the erlang-questions mailing list