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

New command to set master Mnesia node

This commit is contained in:
Badlop 2010-02-15 23:24:37 +01:00
parent 6795675108
commit 8a856df2f0

View File

@ -39,6 +39,7 @@
%% Purge DB %% Purge DB
delete_expired_messages/0, delete_old_messages/1, delete_expired_messages/0, delete_old_messages/1,
%% Mnesia %% Mnesia
set_master/1,
backup_mnesia/1, restore_mnesia/1, backup_mnesia/1, restore_mnesia/1,
dump_mnesia/1, dump_table/2, load_mnesia/1, dump_mnesia/1, dump_table/2, load_mnesia/1,
install_fallback_mnesia/1, install_fallback_mnesia/1,
@ -147,6 +148,12 @@ commands() ->
module = mod_pubsub, function = rename_default_nodeplugin, module = mod_pubsub, function = rename_default_nodeplugin,
args = [], result = {res, rescode}}, args = [], result = {res, rescode}},
#ejabberd_commands{name = set_master, tags = [mnesia],
desc = "Set master node of the clustered Mnesia tables",
longdesc = "If you provie as nodename \"self\", this "
"node will be set as its own master.",
module = ?MODULE, function = set_master,
args = [{nodename, string}], result = {res, restuple}},
#ejabberd_commands{name = mnesia_change_nodename, tags = [mnesia], #ejabberd_commands{name = mnesia_change_nodename, tags = [mnesia],
desc = "Change the erlang node name in a backup file", desc = "Change the erlang node name in a backup file",
module = ?MODULE, function = mnesia_change_nodename, module = ?MODULE, function = mnesia_change_nodename,
@ -339,6 +346,20 @@ delete_old_messages(Days) ->
%%% Mnesia management %%% Mnesia management
%%% %%%
set_master("self") ->
set_master(node());
set_master(NodeString) when is_list(NodeString) ->
set_master(list_to_atom(NodeString));
set_master(Node) when is_atom(Node) ->
case mnesia:set_master_nodes([Node]) of
ok ->
{ok, ""};
{error, Reason} ->
String = io_lib:format("Can't set master node ~p at node ~p:~n~p",
[Node, node(), Reason]),
{error, String}
end.
backup_mnesia(Path) -> backup_mnesia(Path) ->
case mnesia:backup(Path) of case mnesia:backup(Path) of
ok -> ok ->