diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_config.erl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 6fc6c9e34..022590bc5 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -84,7 +84,7 @@ start() -> %% If not specified, the default value 'ejabberd.yml' is assumed. %% @spec () -> string() get_ejabberd_config_path() -> - case application:get_env(config) of + case get_env_config() of {ok, Path} -> Path; undefined -> case os:getenv("EJABBERD_CONFIG_PATH") of @@ -95,6 +95,18 @@ get_ejabberd_config_path() -> end end. +-spec get_env_config() -> {ok, string()} | undefined. +get_env_config() -> + %% First case: the filename can be specified with: erl -config "/path/to/ejabberd.yml". + case application:get_env(config) of + R = {ok, _Path} -> R; + undefined -> + %% Second case for embbeding ejabberd in another app, for example for Elixir: + %% config :ejabberd, + %% file: "config/ejabberd.yml" + application:get_env(ejabberd, file) + end. + %% @doc Read the ejabberd configuration file. %% It also includes additional configuration files and replaces macros. %% This function will crash if finds some error in the configuration file. @@ -679,7 +691,10 @@ is_file_readable(Path) -> end. get_version() -> - list_to_binary(element(2, application:get_key(ejabberd, vsn))). + case application:get_key(ejabberd, vsn) of + undefined -> ""; + {ok, Vsn} -> list_to_binary(Vsn) + end. -spec get_myhosts() -> [binary()]. |