diff --git a/doc/configuration/internal-databases.md b/doc/configuration/internal-databases.md index 1db21a0f396..6d409ca9bb5 100644 --- a/doc/configuration/internal-databases.md +++ b/doc/configuration/internal-databases.md @@ -51,8 +51,9 @@ Namespace for the cluster. Only nodes with the same cluster name would be discov ### `internal_databases.cets.nodelist_file` -File to read a list of nodes from. Relative to the MongooseIM's config directory. This option is for the file backend. +File to read a list of nodes from. Relative to the MongooseIM's release directory. This option is for the file backend. +Required, if `backend = "file"`. * **Syntax:** path. -* **Default:** `"cets_disco.txt"` +* **Default:** not specified. * **Example:** `nodelist_file = "/etc/mim_nodes.txt"` diff --git a/src/config/mongoose_config_spec.erl b/src/config/mongoose_config_spec.erl index b5893caf872..23a5177b5e6 100644 --- a/src/config/mongoose_config_spec.erl +++ b/src/config/mongoose_config_spec.erl @@ -442,12 +442,11 @@ internal_database_cets() -> items = #{<<"backend">> => #option{type = atom, validate = {enum, [file, rdbms]}}, <<"cluster_name">> => #option{type = atom, validate = non_empty}, - %% Relative to the config directory (or an absolute name) + %% Relative to the release directory (or an absolute name) <<"nodelist_file">> => #option{type = string, validate = filename} }, - defaults = #{<<"backend">> => rdbms, <<"cluster_name">> => mongooseim, - <<"nodelist_file">> => "cets_disco.txt"} + defaults = #{<<"backend">> => rdbms, <<"cluster_name">> => mongooseim} }. %% path: internal_databases.*.* diff --git a/src/ejabberd_sup.erl b/src/ejabberd_sup.erl index a097b5b64c3..3a358833da6 100644 --- a/src/ejabberd_sup.erl +++ b/src/ejabberd_sup.erl @@ -194,10 +194,18 @@ cets_specs() -> cets_specs(disabled) -> []; -cets_specs(#{backend := DiscoBackend, cluster_name := ClusterName, - nodelist_file := NodeFile}) -> - ConfigDir = filename:dirname(mongoose_config:get_config_path()), - DiscoFile = filename:join(ConfigDir, NodeFile), +cets_specs(#{backend := DiscoBackend, cluster_name := ClusterName} = Opts) -> + DiscoFile = + case {DiscoBackend, Opts} of + {file, #{nodelist_file := NodeFile}} -> + NodeFile; + {file, _} -> + ?LOG_CRITICAL(#{what => nodelist_file_option_is_required, + text => <<"Specify internal_databases.cets.nodelist_file option">>}), + error(nodelist_file_option_is_required); + _ -> + undefined + end, DiscoOpts = #{ backend_module => disco_backend_to_module(DiscoBackend), cluster_name => atom_to_binary(ClusterName), diff --git a/test/common/config_parser_helper.erl b/test/common/config_parser_helper.erl index 04d5cee0a3e..f535dfdaf23 100644 --- a/test/common/config_parser_helper.erl +++ b/test/common/config_parser_helper.erl @@ -65,8 +65,7 @@ options("miscellaneous") -> {hosts, [<<"localhost">>, <<"anonymous.localhost">>]}, {internal_databases, #{cets => - #{backend => rdbms, cluster_name => mongooseim, - nodelist_file => "cets_disco.txt"}, + #{backend => rdbms, cluster_name => mongooseim}, mnesia => #{}}}, {language, <<"en">>}, {listen, @@ -140,8 +139,7 @@ options("mongooseim-pgsql") -> [<<"localhost">>, <<"anonymous.localhost">>, <<"localhost.bis">>]}, {internal_databases, #{cets => - #{backend => rdbms, cluster_name => mongooseim, - nodelist_file => "cets_disco.txt"}, + #{backend => rdbms, cluster_name => mongooseim}, mnesia => #{}}}, {language, <<"en">>}, {listen, diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index 32442bbf5ec..5de04465947 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -1206,6 +1206,8 @@ test_fast_tls_server(P, T) -> internal_database_cets(_Config) -> CetsEnabled = #{<<"internal_databases">> => #{<<"cets">> => #{}}}, + CetsFile = #{<<"internal_databases">> => #{<<"cets">> => + #{<<"backend">> => <<"file">>, <<"nodelist_file">> => <<"/dev/null">>}}}, %% No internal_databases section means an empty list of databases ?cfg([internal_databases], #{}, #{}), % default %% Empty internal_databases could be configured explicitly @@ -1217,7 +1219,7 @@ internal_database_cets(_Config) -> #{<<"internal_databases">> => #{<<"cets">> => #{<<"cluster_name">> => <<"test">>}}}), ?cfg([internal_databases, cets, cluster_name], mongooseim, CetsEnabled), - ?cfg([internal_databases, cets, nodelist_file], "cets_disco.txt", CetsEnabled), + ?cfg([internal_databases, cets, nodelist_file], "/dev/null", CetsFile), %% If only mnesia section is defined, CETS section is not included ?cfg([internal_databases], #{mnesia => #{}}, #{<<"internal_databases">> => #{<<"mnesia">> => #{}}}),