From 7eda35b945f6d90f4549abfa40145fd3824a1321 Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Fri, 25 Oct 2019 16:02:24 +0300 Subject: [PATCH] Introduce 'gc' ejabberdctl command The command forces garbage collection of all running Erlang processes. The return is always success. --- src/ejabberd_admin.erl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index 2dddb3cad..3e02e6bd0 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -58,6 +58,7 @@ mnesia_change_nodename/4, restore/1, % Still used by some modules clear_cache/0, + gc/0, get_commands_spec/0 ]). %% gen_server callbacks @@ -384,6 +385,10 @@ get_commands_spec() -> #ejabberd_commands{name = clear_cache, tags = [server], desc = "Clear database cache on all nodes", 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}} ]. @@ -834,6 +839,9 @@ clear_cache() -> Nodes = ejabberd_cluster:get_nodes(), 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(). is_my_host(Host) -> try ejabberd_router:is_my_host(Host) -- 2.40.0