25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Start elixir config code only if elixir was enabled in configure script

This commit is contained in:
Paweł Chmielowski 2016-09-08 16:29:19 +02:00
parent ad39da0b0a
commit 4bd45bada7
3 changed files with 39 additions and 14 deletions

View File

@ -74,6 +74,7 @@
{if_var_true, debug, debug_info},
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
{if_var_match, db_type, mssql, {d, 'mssql'}},
{if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
{if_var_true, hipe, native},
{src_dirs, [asn1, src,

View File

@ -255,7 +255,12 @@ register_elixir_config_hooks() ->
end.
start_elixir_application() ->
case ejabberd_config:is_elixir_enabled() of
true ->
case application:ensure_started(elixir) of
ok -> ok;
{error, _Msg} -> ?ERROR_MSG("Elixir application not started.", [])
end;
_ ->
ok
end.

View File

@ -37,7 +37,8 @@
prepare_opt_val/4, convert_table_to_binary/5,
transform_options/1, collect_options/1, default_db/2,
convert_to_yaml/1, convert_to_yaml/2, v_db/2,
env_binary_to_list/2, opt_type/1, may_hide_data/1]).
env_binary_to_list/2, opt_type/1, may_hide_data/1,
is_elixir_enabled/0]).
-export([start/2]).
@ -148,12 +149,17 @@ read_file(File) ->
{include_modules_configs, true}]).
read_file(File, Opts) ->
Terms1 = case 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(File) of
Terms1 = case is_elixir_enabled() of
true ->
case 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(File) of
true ->
'Elixir.Ejabberd.Config':init(File),
'Elixir.Ejabberd.Config':get_ejabberd_opts();
false ->
get_plain_terms_file(File, Opts)
end;
false ->
get_plain_terms_file(File, Opts)
end,
Terms_macros = case proplists:get_bool(replace_macros, Opts) of
true -> replace_macros(Terms1);
@ -1049,9 +1055,22 @@ replace_modules(Modules) ->
%% Elixir module naming
%% ====================
-ifdef(ELIXIR_ENABLED).
is_elixir_enabled() ->
true.
-else.
is_elixir_enabled() ->
false.
-endif.
is_using_elixir_config() ->
case is_elixir_enabled() of
true ->
Config = get_ejabberd_config_path(),
'Elixir.Ejabberd.ConfigUtil':is_elixir_config(Config).
'Elixir.Ejabberd.ConfigUtil':is_elixir_config(Config);
false ->
false
end.
%% If module name start with uppercase letter, this is an Elixir module:
is_elixir_module(Module) ->