Skip to content

Commit

Permalink
adding verification of dynamic_domains feature support at gen_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysGonchar committed Jun 17, 2021
1 parent b094384 commit 6ccae3f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/mongoose.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%% If the ejabberd application description isn't loaded, returns atom: undefined
-define(MONGOOSE_VERSION, element(2, application:get_key(mongooseim,vsn))).

-define(MYHOSTS, ejabberd_config:get_global_option(hosts)).
-define(MYHOSTS, ejabberd_config:get_global_option_or_default(hosts, [])).
-define(ALL_HOST_TYPES, ejabberd_config:get_global_option_or_default(hosts, []) ++
ejabberd_config:get_global_option_or_default(host_types, [])).
-define(MYNAME, ejabberd_config:get_global_option(default_server_domain)).
Expand Down
12 changes: 12 additions & 0 deletions src/gen_mod.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ start_module_for_host_type(HostType, Module, Opts0) ->
try
lists:map(fun mongoose_service:assert_loaded/1,
get_required_services(HostType, Module, Opts)),
check_dynamic_domains_support(HostType, Module),
Res = Module:start(HostType, Opts),
{links, LinksAfter} = erlang:process_info(self(), links),
case lists:sort(LinksBefore) =:= lists:sort(LinksAfter) of
Expand Down Expand Up @@ -184,6 +185,17 @@ start_module_for_host_type(HostType, Module, Opts0) ->
end
end.

check_dynamic_domains_support(HostType, Module) ->
case lists:member(HostType, ?MYHOSTS) of
true -> ok;
false ->
case gen_mod:does_module_support(Module, dynamic_domains) of
true -> ok;
false ->
error({Module, HostType, dynamic_domains_feature_is_not_supported})
end
end.

is_mim_or_ct_running() ->
?MODULE:is_app_running(mongooseim)
%% Common tests would be very confused if we kill the whole node
Expand Down
2 changes: 1 addition & 1 deletion tools/travis-setup-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ elif [ "$db" = 'pgsql' ]; then
# make clean && make
# Than rerun the script to create a new docker container.
echo "Configuring postgres with SSL"
sudo -n service postgresql stop || echo "Failed to stop psql"
sudo -n service postgresql stop || echo "Failed to stop pgsql"
docker rm -v -f $NAME || echo "Skip removing previous container"
cp ${SSLDIR}/mongooseim/cert.pem ${SQL_TEMP_DIR}/fake_cert.pem
cp ${SSLDIR}/mongooseim/key.pem ${SQL_TEMP_DIR}/fake_key.pem
Expand Down

0 comments on commit 6ccae3f

Please sign in to comment.