25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Try db migration only when mnesia is configured (#1458)

This commit is contained in:
Christophe Romain 2017-01-20 09:26:13 +01:00
parent fc2b71a04e
commit 4f5d54f062

View File

@ -262,7 +262,10 @@ init([ServerHost, Opts]) ->
fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS),
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts,
fun(A) when is_integer(A) andalso A >= 0 -> A end, undefined),
[pubsub_index:init(Host, ServerHost, Opts) || gen_mod:db_type(ServerHost, ?MODULE)==mnesia],
case gen_mod:db_type(ServerHost, ?MODULE) of
mnesia -> init_mnesia(Host, ServerHost, Opts);
_ -> ok
end,
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
DefaultModule = plugin(Host, hd(Plugins)),
BaseOptions = DefaultModule:options(),
@ -336,10 +339,6 @@ init([ServerHost, Opts]) ->
false ->
ok
end,
pubsub_migrate:update_node_database(Host, ServerHost),
pubsub_migrate:update_state_database(Host, ServerHost),
pubsub_migrate:update_item_database(Host, ServerHost),
pubsub_migrate:update_lastitem_database(Host, ServerHost),
{_, State} = init_send_loop(ServerHost),
{ok, State}.
@ -382,6 +381,18 @@ depends(ServerHost, Opts) ->
end
end, Plugins).
init_mnesia(Host, ServerHost, Opts) ->
pubsub_index:init(Host, ServerHost, Opts),
spawn(fun() ->
%% maybe upgrade db. this can take time when upgrading existing
%% data from ejabberd 2.1.x, so we don't want this to block
%% calling gen_server:start
pubsub_migrate:update_node_database(Host, ServerHost),
pubsub_migrate:update_state_database(Host, ServerHost),
pubsub_migrate:update_item_database(Host, ServerHost),
pubsub_migrate:update_lastitem_database(Host, ServerHost)
end).
%% @doc Call the init/1 function for each plugin declared in the config file.
%% The default plugin module is implicit.
%% <p>The Erlang code for the plugin is located in a module called