From 909814a34d38ae514b4e309e225d579211165ff8 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sun, 13 Jun 2021 12:33:36 +0200 Subject: [PATCH 1/9] fix(hocon): pin hocon 0.5.1 --- apps/emqx/rebar.config | 2 +- rebar.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx/rebar.config b/apps/emqx/rebar.config index a6e4e6864..7e649ae80 100644 --- a/apps/emqx/rebar.config +++ b/apps/emqx/rebar.config @@ -16,7 +16,7 @@ , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.10.0"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} , {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v4.0.1"}}} %% todo delete when plugins use hocon - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.0"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.1"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} diff --git a/rebar.config b/rebar.config index 696fc6000..109b680c5 100644 --- a/rebar.config +++ b/rebar.config @@ -52,7 +52,7 @@ , {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1 , {getopt, "1.0.1"} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.0"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.1"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}} ]}. From bde5d11078b41fc63757a47625b0eb3688c6a581 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sun, 13 Jun 2021 21:04:33 +0200 Subject: [PATCH 2/9] fix(hocon): call new schema definition functions --- apps/emqx/src/emqx_schema.erl | 18 ++++++++---------- apps/emqx_dashboard/priv/emqx_dashboard.schema | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index 3fb60a6a6..3d2242aa7 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -1180,18 +1180,16 @@ ceiling(X) -> %% types -t(T) -> - fun (type) -> T; (_) -> undefined end. +t(Type) -> hoconsc:t(Type). -t(T, M, D) -> - fun (type) -> T; (mapping) -> M; (default) -> D; (_) -> undefined end. +t(Type, Mapping, Default) -> + hoconsc:t(Type, #{mapping => Mapping, default => Default}). -t(T, M, D, O) -> - fun (type) -> T; - (mapping) -> M; - (default) -> D; - (override_env) -> O; - (_) -> undefined end. +t(Type, Mapping, Default, OverrideEnv) -> + hoconsc:t(Type, #{ mapping => Mapping + , default => Default + , override_env => OverrideEnv + }). ref(Field) -> fun (type) -> Field; (_) -> undefined end. diff --git a/apps/emqx_dashboard/priv/emqx_dashboard.schema b/apps/emqx_dashboard/priv/emqx_dashboard.schema index d485ecdf9..203bb7358 100644 --- a/apps/emqx_dashboard/priv/emqx_dashboard.schema +++ b/apps/emqx_dashboard/priv/emqx_dashboard.schema @@ -7,7 +7,7 @@ {mapping, "dashboard.default_user.password", "emqx_dashboard.default_user_passwd", [ {datatype, string}, - {override_env, "ADMIN_PASSWORD"} + {override_env, "EMQX_ADMIN_PASSWORD"} ]}. {mapping, "dashboard.listener.http.port", "emqx_dashboard.listeners", [ From 992221a4d3d3e99e0c55934a154ee39640e5838c Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sun, 13 Jun 2021 21:21:53 +0200 Subject: [PATCH 3/9] ci: fix bad env variable name --- .ci/build_packages/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/build_packages/tests.sh b/.ci/build_packages/tests.sh index ebd650c1f..ed90bcb4a 100755 --- a/.ci/build_packages/tests.sh +++ b/.ci/build_packages/tests.sh @@ -37,7 +37,7 @@ emqx_test(){ "zip") packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.zip) unzip -q "${PACKAGE_PATH}/${packagename}" - export EMQX_ZONE__EXTERNAL__SERVER__KEEPALIVE=60 \ + export EMQX_ZONE__EXTERNAL__SERVER_KEEPALIVE=60 \ EMQX_MQTT__MAX_TOPIC_ALIAS=10 sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins From 49f844b1ddf1bcb49c335abc7b5f3ce0013437a8 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 14 Jun 2021 18:56:03 +0200 Subject: [PATCH 4/9] feat(bin/emqx): simlified config generation commands --- bin/emqx | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/bin/emqx b/bin/emqx index 96f6ec42f..ed66dee68 100755 --- a/bin/emqx +++ b/bin/emqx @@ -20,6 +20,10 @@ mkdir -p "$RUNNER_LOG_DIR" # Make sure data directory exists mkdir -p "$RUNNER_DATA_DIR" +# Make sure data/configs exists +CONFIGS_DIR="$RUNNER_DATA_DIR/configs" +mkdir -p "$CONFIGS_DIR" + # hocon try to read environment variables starting with "EMQX_" export HOCON_ENV_OVERRIDE_PREFIX='EMQX_' @@ -204,39 +208,48 @@ generate_config() { EMQX_LICENSE_CONF_OPTION="-c ${EMQX_LICENSE_CONF}" fi - set +e - # disable shellcheck; let EMQX_LICENSE_CONF_OPTION split + ## timestamp for each generation + local NOW_TIME + NOW_TIME="$("$ERTS_PATH"/escript "$RUNNER_ROOT_DIR"/bin/hocon now_time)" + + ## ths command populates two files: app.