diff --git a/apps/emqx/src/emqx.erl b/apps/emqx/src/emqx.erl index 2c3f4d1c5..bd5bb083d 100644 --- a/apps/emqx/src/emqx.erl +++ b/apps/emqx/src/emqx.erl @@ -275,8 +275,9 @@ etc_file(SubPath) -> filename:join([etc_dir(), SubPath]). etc_dir() -> - %% EMQX_ETC_DIR is inherited from RUNNER_ETC_DIR which is set at package build time. - %% when it's not set, it's most likely when running test cases. + %% EMQX_ETC_DIR set by emqx boot script, + %% if it's not set, then it must be test environment + %% which should uses default path Env = os:getenv("EMQX_ETC_DIR"), case Env =:= "" orelse Env =:= false of true -> "etc"; diff --git a/apps/emqx_conf/src/emqx_conf_schema.erl b/apps/emqx_conf/src/emqx_conf_schema.erl index 0af6bb97c..ee9e3396b 100644 --- a/apps/emqx_conf/src/emqx_conf_schema.erl +++ b/apps/emqx_conf/src/emqx_conf_schema.erl @@ -830,7 +830,7 @@ tr_config_files(Conf) -> [_ | _] = Files -> Files; _ -> - case os:getenv("RUNNER_ETC_DIR") of + case os:getenv("EMQX_ETC_DIR") of false -> [filename:join([code:lib_dir(emqx), "etc", "emqx.conf"])]; Dir -> diff --git a/bin/emqx b/bin/emqx index 6708739c4..a7fad3589 100755 --- a/bin/emqx +++ b/bin/emqx @@ -15,17 +15,10 @@ ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)" # defined in emqx_vars export RUNNER_ROOT_DIR -export RUNNER_ETC_DIR +export EMQX_ETC_DIR export REL_VSN export SCHEMA_MOD -# RUNNER_ETC_DIR is only used at boot time -# EMQX_ETC_DIR is by default RUNNER_ETC_DIR but the absolute path -# it is used at runtime by the emqx program -# so that it won't change even if file:set_cwd is evaluated by EMQX later -EMQX_ETC_DIR="${EMQX_ETC_DIR:-$(cd "$(readlink "$RUNNER_ETC_DIR")"; pwd -P)}" -export EMQX_ETC_DIR - RUNNER_SCRIPT="$RUNNER_BIN_DIR/$REL_NAME" CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}" REL_DIR="$RUNNER_ROOT_DIR/releases/$REL_VSN" @@ -362,7 +355,7 @@ call_hocon() { get_config_value() { path_to_value="$1" - call_hocon -s "$SCHEMA_MOD" -c "$RUNNER_ETC_DIR"/emqx.conf get "$path_to_value" | tr -d \" + call_hocon -s "$SCHEMA_MOD" -c "$EMQX_ETC_DIR"/emqx.conf get "$path_to_value" | tr -d \" } check_license() { @@ -425,7 +418,7 @@ generate_config() { ## NOTE: the generate command merges environment variables to the base config (emqx.conf), ## but does not include the cluster-override.conf and local-override.conf ## meaning, certain overrides will not be mapped to app.