问题
I notice there is the code as follows in cowboy https://github.com/extend/cowboy
supervisor:start_child(cowboy_sup, child_spec(Ref, NbAcceptors,
Transport, TransOpts, Protocol, ProtoOpts)).
child_spec(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->
{{cowboy_listener_sup, Ref}, {cowboy_listener_sup, start_link, [ NbAcceptors, Transport,
TransOpts, Protocol, ProtoOpts ]}, permanent, 5000, supervisor,[cowboy_listener_sup]}.
http://www.erlang.org/doc/man/supervisor.html#start_child-2
I don't think it is correct child spec, what do you think about it ?
回答1:
You can verify the correctness of a child spec by using the supervisor:check_childspecs/1 function.
And yes, that looks like a valid child spec:
child_spec() =
{Id :: child_id(),
StartFunc :: mfargs(),
Restart :: restart(),
Shutdown :: shutdown(),
Type :: worker(),
Modules :: modules()}
Where:
Id -> {cowboy_listener_sup, Ref}
StartFunc -> {cowboy_listener_sup, start_link, [ ... ]}
Restart -> permanent
Shutdown -> 5000
Type -> supervisor
Modules -> [cowboy_listener_sup]
What's the doubt, exactly?
来源:https://stackoverflow.com/questions/10104014/is-this-a-correct-child-spec