25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Introduce 'gc' ejabberdctl command

The command forces garbage collection of all running Erlang processes.
The return is always success.
This commit is contained in:
Evgeny Khramtsov 2019-10-25 16:02:24 +03:00
parent e8fe68543e
commit 7eda35b945

View File

@ -58,6 +58,7 @@
mnesia_change_nodename/4, mnesia_change_nodename/4,
restore/1, % Still used by some modules restore/1, % Still used by some modules
clear_cache/0, clear_cache/0,
gc/0,
get_commands_spec/0 get_commands_spec/0
]). ]).
%% gen_server callbacks %% gen_server callbacks
@ -384,6 +385,10 @@ get_commands_spec() ->
#ejabberd_commands{name = clear_cache, tags = [server], #ejabberd_commands{name = clear_cache, tags = [server],
desc = "Clear database cache on all nodes", desc = "Clear database cache on all nodes",
module = ?MODULE, function = clear_cache, module = ?MODULE, function = clear_cache,
args = [], result = {res, rescode}},
#ejabberd_commands{name = gc, tags = [server],
desc = "Force full garbage collection",
module = ?MODULE, function = gc,
args = [], result = {res, rescode}} args = [], result = {res, rescode}}
]. ].
@ -834,6 +839,9 @@ clear_cache() ->
Nodes = ejabberd_cluster:get_nodes(), Nodes = ejabberd_cluster:get_nodes(),
lists:foreach(fun(T) -> ets_cache:clear(T, Nodes) end, ets_cache:all()). lists:foreach(fun(T) -> ets_cache:clear(T, Nodes) end, ets_cache:all()).
gc() ->
lists:foreach(fun erlang:garbage_collect/1, processes()).
-spec is_my_host(binary()) -> boolean(). -spec is_my_host(binary()) -> boolean().
is_my_host(Host) -> is_my_host(Host) ->
try ejabberd_router:is_my_host(Host) try ejabberd_router:is_my_host(Host)