Reputation: 24851
I have a function in my_sup.erl like this:
init([ems_media_sup]) ->
{ok, {{simple_one_for_one, ?MAX_RESTART, ?MAX_TIME}, [
{ems_media_sup, {ems_media, start_link, []}, temporary, 2000, worker, [ems_media]}]
}};
But there is no function named start_link/1 in ems_media.erl, I want to know why there is no error when run
supervisor:start_link(?MODULE, [ems_media_sup])
So, How to know what happened next after call init([ems_media_sup])
Upvotes: 1
Views: 185
Reputation: 41528
That's because my_sup
is of type simple_one_for_one
- so it will only start child processes when explicitly asked to do so through supervisor:start_child/2.
If the supervisor had been of any other type (one_for_one
, one_for_all
or rest_for_one
) it would have attempted to start all children in the child specification at startup, but a simple_one_for_one
supervisor is for creating large numbers of children that only vary by their argument list, so in that case the child specification in the init
function only plays the role of a template.
Upvotes: 3