mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix listeners child specs creation
This commit is contained in:
parent
29f6c43ae3
commit
3cc964fbcc
@ -62,33 +62,31 @@ start_link() ->
|
|||||||
init(_) ->
|
init(_) ->
|
||||||
ets:new(?MODULE, [named_table, public]),
|
ets:new(?MODULE, [named_table, public]),
|
||||||
ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50),
|
ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50),
|
||||||
case listeners_childspec() of
|
Listeners = ejabberd_config:get_option(listen, []),
|
||||||
{ok, Specs} -> {ok, {{one_for_one, 10, 1}, Specs}};
|
case add_certfiles(Listeners) of
|
||||||
{error, _} = Err -> Err
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec listeners_childspec() -> {ok, [supervisor:child_spec()]} | {error, any()}.
|
|
||||||
listeners_childspec() ->
|
|
||||||
Ls = ejabberd_config:get_option(listen, []),
|
|
||||||
case add_certfiles(Ls) of
|
|
||||||
ok ->
|
ok ->
|
||||||
{ok, lists:map(
|
{ok, {{one_for_one, 10, 1}, listeners_childspec(Listeners)}};
|
||||||
fun({EndPoint, Module, Opts}) ->
|
|
||||||
ets:insert(?MODULE, {EndPoint, Module, Opts}),
|
|
||||||
{EndPoint,
|
|
||||||
{?MODULE, start, [EndPoint, Module, Opts]},
|
|
||||||
transient, brutal_kill, worker, [?MODULE]}
|
|
||||||
end, Ls)};
|
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
Err
|
Err
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec listeners_childspec([listener()]) -> [supervisor:child_spec()].
|
||||||
|
listeners_childspec(Listeners) ->
|
||||||
|
lists:map(
|
||||||
|
fun({EndPoint, Module, Opts}) ->
|
||||||
|
ets:insert(?MODULE, {EndPoint, Module, Opts}),
|
||||||
|
{EndPoint,
|
||||||
|
{?MODULE, start, [EndPoint, Module, Opts]},
|
||||||
|
transient, brutal_kill, worker, [?MODULE]}
|
||||||
|
end, Listeners).
|
||||||
|
|
||||||
-spec start_listeners() -> ok.
|
-spec start_listeners() -> ok.
|
||||||
start_listeners() ->
|
start_listeners() ->
|
||||||
|
Listeners = ejabberd_config:get_option(listen, []),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Spec) ->
|
fun(Spec) ->
|
||||||
supervisor:start_child(?MODULE, Spec)
|
supervisor:start_child(?MODULE, Spec)
|
||||||
end, listeners_childspec()).
|
end, listeners_childspec(Listeners)).
|
||||||
|
|
||||||
-spec start(endpoint(), module(), listen_opts()) -> term().
|
-spec start(endpoint(), module(), listen_opts()) -> term().
|
||||||
start(EndPoint, Module, Opts) ->
|
start(EndPoint, Module, Opts) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user