diff options
author | Badlop <badlop@process-one.net> | 2011-05-16 22:33:08 +0200 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-05-16 22:33:59 +0200 |
commit | f7d532f2f74ef85fe62f1e7645be0276153b54cf (patch) | |
tree | 8005589f7c29348f70a5abd2d18438da88b30a13 | |
parent | Note that ejabberd works with CGP LDAP server (diff) |
When module start fails during server start, stop erlang (EJAB-1446)
-rw-r--r-- | src/gen_mod.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/gen_mod.erl b/src/gen_mod.erl index d817dc24..397cbc35 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -70,11 +70,24 @@ start_module(Host, Module, Opts) -> catch Class:Reason -> del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), - ?ERROR_MSG("Problem starting the module ~p for host ~p with options:~n ~p~n ~p: ~p", + ErrorText = io_lib:format("Problem starting the module ~p for host ~p ~n options: ~p~n ~p: ~p", [Module, Host, Opts, Class, Reason]), - erlang:raise(Class, Reason, erlang:get_stacktrace()) + ?CRITICAL_MSG(ErrorText, []), + case is_app_running(ejabberd) of + true -> + erlang:raise(Class, Reason, erlang:get_stacktrace()); + false -> + ?CRITICAL_MSG("ejabberd initialization was aborted because a module start failed.", []), + timer:sleep(3000), + erlang:halt(lists:flatten(ErrorText)) + end end. +is_app_running(AppName) -> + %% Use a high timeout to prevent a false positive in a high load system + Timeout = 15000, + lists:keymember(AppName, 1, application:which_applications(Timeout)). + %% @doc Stop the module in a host, and forget its configuration. stop_module(Host, Module) -> case stop_module_keep_config(Host, Module) of |