aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_app.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2008-02-28 00:30:23 +0000
committerBadlop <badlop@process-one.net>2008-02-28 00:30:23 +0000
commit22a5bce9de9623e4b189b34319e59ddf84f828ea (patch)
tree0e8f28af4715715759543b5bd7f85f0affec4775 /src/ejabberd_app.erl
parent* src/ejabberd_check.erl: Separate config loading from configuration sanity c... (diff)
* src/ejabberd_app.erl (prep_stop): Stop modules when stopping
ejabberd (EJAB-536) * src/mod_caps.erl (stop): Probably not needed to stop supervisor child (EJAB-536) * src/mod_muc/mod_muc.erl (room_destroyed): Catch message sending (EJAB-536) * src/mod_muc/mod_muc_room.erl (init): Ensure rooms are called when the process dies due to a linked die (EJAB-536) SVN Revision: 1212
Diffstat (limited to 'src/ejabberd_app.erl')
-rw-r--r--src/ejabberd_app.erl46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl
index d400336e2..4c12069d1 100644
--- a/src/ejabberd_app.erl
+++ b/src/ejabberd_app.erl
@@ -1,7 +1,7 @@
%%%----------------------------------------------------------------------
%%% File : ejabberd_app.erl
%%% Author : Alexey Shchepin <alexey@process-one.net>
-%%% Purpose : ejabberd OTP application definition.
+%%% Purpose : ejabberd's application callback module
%%% Created : 31 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
%%%
%%%
@@ -29,10 +29,15 @@
-behaviour(application).
--export([start/2, stop/1, init/0]).
+-export([start/2, prep_stop/1, stop/1, init/0]).
-include("ejabberd.hrl").
+
+%%%
+%%% Application API
+%%%
+
start(normal, _Args) ->
ejabberd_loglevel:set(4),
application:start(sasl),
@@ -57,14 +62,27 @@ start(normal, _Args) ->
%eprof:start(),
%eprof:profile([self()]),
%fprof:trace(start, "/tmp/fprof"),
- load_modules(),
+ start_modules(),
Sup;
start(_, _) ->
{error, badarg}.
-stop(_StartArgs) ->
+%% Prepare the application for termination.
+%% This function is called when an application is about to be stopped,
+%% before shutting down the processes of the application.
+prep_stop(State) ->
+ stop_modules(),
+ State.
+
+%% All the processes were killed when this function is called
+stop(_State) ->
ok.
+
+%%%
+%%% Internal functions
+%%%
+
start() ->
spawn_link(?MODULE, init, []).
@@ -110,7 +128,8 @@ db_init() ->
mnesia:start(),
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).
-load_modules() ->
+%% Start all the modules in all the hosts
+start_modules() ->
lists:foreach(
fun(Host) ->
case ejabberd_config:get_local_option({modules, Host}) of
@@ -124,6 +143,21 @@ load_modules() ->
end
end, ?MYHOSTS).
+%% Stop all the modules in all the hosts
+stop_modules() ->
+ lists:foreach(
+ fun(Host) ->
+ case ejabberd_config:get_local_option({modules, Host}) of
+ undefined ->
+ ok;
+ Modules ->
+ lists:foreach(
+ fun({Module, _Args}) ->
+ gen_mod:stop_module(Host, Module)
+ end, Modules)
+ end
+ end, ?MYHOSTS).
+
connect_nodes() ->
case ejabberd_config:get_local_option(cluster_nodes) of
undefined ->
@@ -134,5 +168,3 @@ connect_nodes() ->
end, Nodes)
end.
-
-