From 35a076c2517bf36ff5afb5bb38a674291a1ec607 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 9 May 2018 11:44:24 +0300 Subject: Stop ejabberd initialization on invalid/unknown options Since now, ejabberd doesn't ignore unknown options and doesn't allow to have options with malformed values. The rationale for this is to avoid unexpected behaviour during runtime, i.e. to conform to "fail early" approach. Note that it's safe to reload a configuration with potentialy invalid and/or unknown options: this will not halt ejabberd, but will only prevent the configuration from loading. ***NOTE FOR PACKAGE BUILDERS*** This new behaviour should be documented in the upgrade notes. --- src/ejabberd_app.erl | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/ejabberd_app.erl') diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index f1066815..c7486a5b 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -46,22 +46,27 @@ start(normal, _Args) -> start_elixir_application(), ejabberd:check_app(ejabberd), setup_if_elixir_conf_used(), - ejabberd_config:start(), - ejabberd_mnesia:start(), - file_queue_init(), - maybe_add_nameservers(), - ejabberd_system_monitor:start(), - case ejabberd_sup:start_link() of - {ok, SupPid} -> - register_elixir_config_hooks(), - ejabberd_cluster:wait_for_sync(infinity), - {T2, _} = statistics(wall_clock), - ?INFO_MSG("ejabberd ~s is started in the node ~p in ~.2fs", - [?VERSION, node(), (T2-T1)/1000]), - lists:foreach(fun erlang:garbage_collect/1, processes()), - {ok, SupPid}; - Err -> - ?CRITICAL_MSG("Failed to start ejabberd application: ~p", [Err]), + case ejabberd_config:start() of + ok -> + ejabberd_mnesia:start(), + file_queue_init(), + maybe_add_nameservers(), + ejabberd_system_monitor:start(), + case ejabberd_sup:start_link() of + {ok, SupPid} -> + register_elixir_config_hooks(), + ejabberd_cluster:wait_for_sync(infinity), + {T2, _} = statistics(wall_clock), + ?INFO_MSG("ejabberd ~s is started in the node ~p in ~.2fs", + [?VERSION, node(), (T2-T1)/1000]), + lists:foreach(fun erlang:garbage_collect/1, processes()), + {ok, SupPid}; + Err -> + ?CRITICAL_MSG("Failed to start ejabberd application: ~p", [Err]), + ejabberd:halt() + end; + {error, Reason} -> + ?CRITICAL_MSG("Failed to start ejabberd application: ~p", [Reason]), ejabberd:halt() end; start(_, _) -> -- cgit v1.2.3