mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-21 14:06:57 +02:00
Merge branch 'master' of github.com:processone/ejabberd
This commit is contained in:
commit
6d7891ed16
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
-behaviour(application).
|
-behaviour(application).
|
||||||
|
|
||||||
-export([start_modules/0, start/2, prep_stop/1, stop/1,
|
-export([start/2, prep_stop/1, stop/1,
|
||||||
init/0, opt_type/1]).
|
init/0, opt_type/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -71,7 +71,7 @@ start(normal, _Args) ->
|
|||||||
maybe_add_nameservers(),
|
maybe_add_nameservers(),
|
||||||
ejabberd_auth:start(),
|
ejabberd_auth:start(),
|
||||||
ejabberd_oauth:start(),
|
ejabberd_oauth:start(),
|
||||||
start_modules(),
|
gen_mod:start_modules(),
|
||||||
ejabberd_listener:start_listeners(),
|
ejabberd_listener:start_listeners(),
|
||||||
?INFO_MSG("ejabberd ~s is started in the node ~p", [?VERSION, node()]),
|
?INFO_MSG("ejabberd ~s is started in the node ~p", [?VERSION, node()]),
|
||||||
Sup;
|
Sup;
|
||||||
@ -83,7 +83,7 @@ start(_, _) ->
|
|||||||
%% before shutting down the processes of the application.
|
%% before shutting down the processes of the application.
|
||||||
prep_stop(State) ->
|
prep_stop(State) ->
|
||||||
ejabberd_listener:stop_listeners(),
|
ejabberd_listener:stop_listeners(),
|
||||||
stop_modules(),
|
gen_mod:stop_modules(),
|
||||||
ejabberd_admin:stop(),
|
ejabberd_admin:stop(),
|
||||||
broadcast_c2s_shutdown(),
|
broadcast_c2s_shutdown(),
|
||||||
timer:sleep(5000),
|
timer:sleep(5000),
|
||||||
@ -137,42 +137,6 @@ db_init() ->
|
|||||||
ejabberd:start_app(mnesia, permanent),
|
ejabberd:start_app(mnesia, permanent),
|
||||||
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).
|
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).
|
||||||
|
|
||||||
%% Start all the modules in all the hosts
|
|
||||||
start_modules() ->
|
|
||||||
lists:foreach(
|
|
||||||
fun(Host) ->
|
|
||||||
Modules = ejabberd_config:get_option(
|
|
||||||
{modules, Host},
|
|
||||||
fun(Mods) ->
|
|
||||||
lists:map(
|
|
||||||
fun({M, A}) when is_atom(M), is_list(A) ->
|
|
||||||
{M, A}
|
|
||||||
end, Mods)
|
|
||||||
end, []),
|
|
||||||
lists:foreach(
|
|
||||||
fun({Module, Args}) ->
|
|
||||||
gen_mod:start_module(Host, Module, Args)
|
|
||||||
end, Modules)
|
|
||||||
end, ?MYHOSTS).
|
|
||||||
|
|
||||||
%% Stop all the modules in all the hosts
|
|
||||||
stop_modules() ->
|
|
||||||
lists:foreach(
|
|
||||||
fun(Host) ->
|
|
||||||
Modules = ejabberd_config:get_option(
|
|
||||||
{modules, Host},
|
|
||||||
fun(Mods) ->
|
|
||||||
lists:map(
|
|
||||||
fun({M, A}) when is_atom(M), is_list(A) ->
|
|
||||||
{M, A}
|
|
||||||
end, Mods)
|
|
||||||
end, []),
|
|
||||||
lists:foreach(
|
|
||||||
fun({Module, _Args}) ->
|
|
||||||
gen_mod:stop_module_keep_config(Host, Module)
|
|
||||||
end, Modules)
|
|
||||||
end, ?MYHOSTS).
|
|
||||||
|
|
||||||
connect_nodes() ->
|
connect_nodes() ->
|
||||||
Nodes = ejabberd_config:get_option(
|
Nodes = ejabberd_config:get_option(
|
||||||
cluster_nodes,
|
cluster_nodes,
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
get_module_opt/4, get_module_opt/5, get_module_opt_host/3,
|
get_module_opt/4, get_module_opt/5, get_module_opt_host/3,
|
||||||
loaded_modules/1, loaded_modules_with_opts/1,
|
loaded_modules/1, loaded_modules_with_opts/1,
|
||||||
get_hosts/2, get_module_proc/2, is_loaded/2,
|
get_hosts/2, get_module_proc/2, is_loaded/2,
|
||||||
start_modules/1, default_db/1, v_db/1, opt_type/1]).
|
start_modules/0, start_modules/1, stop_modules/0, stop_modules/1,
|
||||||
|
default_db/1, v_db/1, opt_type/1]).
|
||||||
|
|
||||||
%%-export([behaviour_info/1]).
|
%%-export([behaviour_info/1]).
|
||||||
|
|
||||||
@ -64,12 +65,29 @@ start() ->
|
|||||||
{keypos, #ejabberd_module.module_host}]),
|
{keypos, #ejabberd_module.module_host}]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
-spec start_modules() -> any().
|
||||||
|
|
||||||
|
%% Start all the modules in all the hosts
|
||||||
|
start_modules() ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(Host) ->
|
||||||
|
start_modules(Host)
|
||||||
|
end, ?MYHOSTS).
|
||||||
|
|
||||||
|
get_modules_options(Host) ->
|
||||||
|
ejabberd_config:get_option(
|
||||||
|
{modules, Host},
|
||||||
|
fun(Mods) ->
|
||||||
|
lists:map(
|
||||||
|
fun({M, A}) when is_atom(M), is_list(A) ->
|
||||||
|
{M, A}
|
||||||
|
end, Mods)
|
||||||
|
end, []).
|
||||||
|
|
||||||
-spec start_modules(binary()) -> any().
|
-spec start_modules(binary()) -> any().
|
||||||
|
|
||||||
start_modules(Host) ->
|
start_modules(Host) ->
|
||||||
Modules = ejabberd_config:get_option(
|
Modules = get_modules_options(Host),
|
||||||
{modules, Host},
|
|
||||||
fun(L) when is_list(L) -> L end, []),
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({Module, Opts}) ->
|
fun({Module, Opts}) ->
|
||||||
start_module(Host, Module, Opts)
|
start_module(Host, Module, Opts)
|
||||||
@ -78,9 +96,7 @@ start_modules(Host) ->
|
|||||||
-spec start_module(binary(), atom()) -> any().
|
-spec start_module(binary(), atom()) -> any().
|
||||||
|
|
||||||
start_module(Host, Module) ->
|
start_module(Host, Module) ->
|
||||||
Modules = ejabberd_config:get_option(
|
Modules = get_modules_options(Host),
|
||||||
{modules, Host},
|
|
||||||
fun(L) when is_list(L) -> L end, []),
|
|
||||||
case lists:keyfind(Module, 1, Modules) of
|
case lists:keyfind(Module, 1, Modules) of
|
||||||
{_, Opts} ->
|
{_, Opts} ->
|
||||||
start_module(Host, Module, Opts);
|
start_module(Host, Module, Opts);
|
||||||
@ -121,6 +137,23 @@ is_app_running(AppName) ->
|
|||||||
lists:keymember(AppName, 1,
|
lists:keymember(AppName, 1,
|
||||||
application:which_applications(Timeout)).
|
application:which_applications(Timeout)).
|
||||||
|
|
||||||
|
-spec stop_modules() -> any().
|
||||||
|
|
||||||
|
stop_modules() ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(Host) ->
|
||||||
|
stop_modules(Host)
|
||||||
|
end, ?MYHOSTS).
|
||||||
|
|
||||||
|
-spec stop_modules(binary()) -> any().
|
||||||
|
|
||||||
|
stop_modules(Host) ->
|
||||||
|
Modules = get_modules_options(Host),
|
||||||
|
lists:foreach(
|
||||||
|
fun({Module, _Args}) ->
|
||||||
|
gen_mod:stop_module_keep_config(Host, Module)
|
||||||
|
end, Modules).
|
||||||
|
|
||||||
-spec stop_module(binary(), atom()) -> error | {aborted, any()} | {atomic, any()}.
|
-spec stop_module(binary(), atom()) -> error | {aborted, any()} | {atomic, any()}.
|
||||||
|
|
||||||
stop_module(Host, Module) ->
|
stop_module(Host, Module) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user