mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Improve ejabberd halting procedure
This commit is contained in:
parent
a54694684d
commit
0aa004bafc
@ -98,7 +98,9 @@ start_included_apps() ->
|
||||
prep_stop(State) ->
|
||||
ejabberd_hooks:run(ejabberd_stopping, []),
|
||||
ejabberd_listener:stop_listeners(),
|
||||
_ = ejabberd_sm:stop(),
|
||||
ejabberd_sm:stop(),
|
||||
ejabberd_service:stop(),
|
||||
ejabberd_s2s:stop(),
|
||||
gen_mod:stop_modules(),
|
||||
State.
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
-behaviour(gen_server).
|
||||
|
||||
%% API
|
||||
-export([start_link/0, route/1, have_connection/1,
|
||||
-export([start_link/0, stop/0, route/1, have_connection/1,
|
||||
get_connections_pids/1, try_register/1,
|
||||
remove_connection/2, start_connection/2, start_connection/3,
|
||||
dirty_get_connections/0, allow_host/2,
|
||||
@ -76,6 +76,12 @@
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
-spec stop() -> ok.
|
||||
stop() ->
|
||||
_ = supervisor:terminate_child(ejabberd_sup, ?MODULE),
|
||||
_ = supervisor:delete_child(ejabberd_sup, ?MODULE),
|
||||
ok.
|
||||
|
||||
clean_temporarily_blocked_table() ->
|
||||
mnesia:clear_table(temporarily_blocked).
|
||||
|
||||
|
@ -26,14 +26,14 @@
|
||||
-protocol({xep, 114, '1.6'}).
|
||||
|
||||
%% ejabberd_listener callbacks
|
||||
-export([start/3, start_link/3, accept/1]).
|
||||
-export([start/3, start_link/3, stop/0, accept/1]).
|
||||
-export([listen_opt_type/1, listen_options/0]).
|
||||
%% xmpp_stream_in callbacks
|
||||
-export([init/1, handle_info/2, terminate/2, code_change/3]).
|
||||
-export([handle_stream_start/2, handle_auth_success/4, handle_auth_failure/4,
|
||||
handle_authenticated_packet/2, get_password_fun/1, tls_options/1]).
|
||||
%% API
|
||||
-export([send/2, close/1, close/2]).
|
||||
-export([send/2, close/1, close/2, stop/1]).
|
||||
|
||||
-include("xmpp.hrl").
|
||||
-include("logger.hrl").
|
||||
@ -53,6 +53,19 @@ start_link(SockMod, Socket, Opts) ->
|
||||
xmpp_stream_in:start_link(?MODULE, [{SockMod, Socket}, Opts],
|
||||
ejabberd_config:fsm_limit_opts(Opts)).
|
||||
|
||||
-spec stop() -> ok.
|
||||
stop() ->
|
||||
Err = xmpp:serr_system_shutdown(),
|
||||
lists:foreach(
|
||||
fun({_Id, Pid, _Type, _Module}) ->
|
||||
send(Pid, Err),
|
||||
stop(Pid),
|
||||
supervisor:terminate_child(ejabberd_service_sup, Pid)
|
||||
end, supervisor:which_children(ejabberd_service_sup)),
|
||||
_ = supervisor:terminate_child(ejabberd_sup, ejabberd_service_sup),
|
||||
_ = supervisor:delete_child(ejabberd_sup, ejabberd_service_sup),
|
||||
ok.
|
||||
|
||||
accept(Ref) ->
|
||||
xmpp_stream_in:accept(Ref).
|
||||
|
||||
@ -70,6 +83,11 @@ close(Ref) ->
|
||||
close(Ref, Reason) ->
|
||||
xmpp_stream_in:close(Ref, Reason).
|
||||
|
||||
-spec stop(pid()) -> ok;
|
||||
(state()) -> no_return().
|
||||
stop(Ref) ->
|
||||
xmpp_stream_in:stop(Ref).
|
||||
|
||||
%%%===================================================================
|
||||
%%% xmpp_stream_in callbacks
|
||||
%%%===================================================================
|
||||
|
@ -115,12 +115,13 @@
|
||||
start_link() ->
|
||||
?GEN_SERVER:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
-spec stop() -> ok | {error, atom()}.
|
||||
-spec stop() -> ok.
|
||||
stop() ->
|
||||
case supervisor:terminate_child(ejabberd_sup, ?MODULE) of
|
||||
ok -> supervisor:delete_child(ejabberd_sup, ?MODULE);
|
||||
Err -> Err
|
||||
end.
|
||||
_ = supervisor:terminate_child(ejabberd_sup, ?MODULE),
|
||||
_ = supervisor:delete_child(ejabberd_sup, ?MODULE),
|
||||
_ = supervisor:terminate_child(ejabberd_sup, ejabberd_c2s_sup),
|
||||
_ = supervisor:delete_child(ejabberd_sup, ejabberd_c2s_sup),
|
||||
ok.
|
||||
|
||||
-spec route(jid(), term()) -> ok.
|
||||
%% @doc route arbitrary term to c2s process(es)
|
||||
|
Loading…
Reference in New Issue
Block a user