Browse Source

feat: Added emqx command to check configs

Chris 3 years atrás
parent
commit
24f88679ae
5 changed files with 19 additions and 5 deletions
  1. 1 1
      apps/emqx/rebar.config
  2. 1 1
      apps/emqx_prometheus/rebar.config
  3. 15 1
      bin/emqx
  4. 1 1
      mix.exs
  5. 1 1
      rebar.config

+ 1 - 1
apps/emqx/rebar.config

@@ -29,7 +29,7 @@
     {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.3"}}},
     {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.3"}}},
     {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.13.2"}}},
     {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.13.2"}}},
     {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}},
     {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}},
-    {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.28.3"}}},
+    {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.29.0"}}},
     {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}},
     {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}},
     {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}},
     {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}},
     {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.0"}}}
     {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.0"}}}

+ 1 - 1
apps/emqx_prometheus/rebar.config

@@ -4,7 +4,7 @@
     {emqx, {path, "../emqx"}},
     {emqx, {path, "../emqx"}},
     %% FIXME: tag this as v3.1.3
     %% FIXME: tag this as v3.1.3
     {prometheus, {git, "https://github.com/deadtrickster/prometheus.erl", {tag, "v4.8.1"}}},
     {prometheus, {git, "https://github.com/deadtrickster/prometheus.erl", {tag, "v4.8.1"}}},
-    {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.28.3"}}}
+    {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.29.0"}}}
 ]}.
 ]}.
 
 
 {edoc_opts, [{preprocess, true}]}.
 {edoc_opts, [{preprocess, true}]}.

+ 15 - 1
bin/emqx

@@ -169,6 +169,9 @@ usage() {
         echo "     --no-permanent   Install release package VERSION but"
         echo "     --no-permanent   Install release package VERSION but"
         echo "                      don't make it permanent"
         echo "                      don't make it permanent"
         ;;
         ;;
+    check_config)
+        echo "Checks the EMQX config without generating any files"
+        ;;
     *)
     *)
         echo "Usage: $REL_NAME COMMAND [help]"
         echo "Usage: $REL_NAME COMMAND [help]"
         echo ''
         echo ''
@@ -184,6 +187,7 @@ usage() {
         echo "  Up/Down-grade: upgrade | downgrade | install | uninstall"
         echo "  Up/Down-grade: upgrade | downgrade | install | uninstall"
         echo "  Install info:  ertspath | root_dir"
         echo "  Install info:  ertspath | root_dir"
         echo "  Runtime info:  pid | ping | versions"
         echo "  Runtime info:  pid | ping | versions"
+        echo "  Validate Config:  check_config"
         echo "  Advanced:      console_clean | escript | rpc | rpcterms | eval | eval-erl"
         echo "  Advanced:      console_clean | escript | rpc | rpcterms | eval | eval-erl"
         echo ''
         echo ''
         echo "Execute '$REL_NAME COMMAND help' for more information"
         echo "Execute '$REL_NAME COMMAND help' for more information"
@@ -211,7 +215,7 @@ fi
 
 
 ## IS_BOOT_COMMAND is set for later to inspect node name and cookie from hocon config (or env variable)
 ## IS_BOOT_COMMAND is set for later to inspect node name and cookie from hocon config (or env variable)
 case "${COMMAND}" in
 case "${COMMAND}" in
-    start|console|console_clean|foreground)
+    start|console|console_clean|foreground|check_config)
         IS_BOOT_COMMAND='yes'
         IS_BOOT_COMMAND='yes'
         ;;
         ;;
     ertspath)
     ertspath)
@@ -525,6 +529,12 @@ relx_start_command() {
            "$START_OPTION"
            "$START_OPTION"
 }
 }
 
 
+# Function to check configs without generating them
+check_config() {
+    ## this command checks the configs without generating any files
+    call_hocon -v -s "$SCHEMA_MOD" -c "$EMQX_ETC_DIR"/emqx.conf check_schema
+}
+
 # Function to generate app.config and vm.args
 # Function to generate app.config and vm.args
 # sets two environment variables CONF_FILE and ARGS_FILE
 # sets two environment variables CONF_FILE and ARGS_FILE
 generate_config() {
 generate_config() {
@@ -1030,6 +1040,10 @@ case "${COMMAND}" in
         shift
         shift
         relx_nodetool "eval" "$@"
         relx_nodetool "eval" "$@"
         ;;
         ;;
+
+    check_config)
+        check_config
+        ;;
     *)
     *)
         usage "$COMMAND"
         usage "$COMMAND"
         exit 1
         exit 1

+ 1 - 1
mix.exs

@@ -66,7 +66,7 @@ defmodule EMQXUmbrella.MixProject do
       # in conflict by emqtt and hocon
       # in conflict by emqtt and hocon
       {:getopt, "1.0.2", override: true},
       {:getopt, "1.0.2", override: true},
       {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "1.0.0", override: true},
       {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "1.0.0", override: true},
-      {:hocon, github: "emqx/hocon", tag: "0.28.3", override: true},
+      {:hocon, github: "emqx/hocon", tag: "0.29.0", override: true},
       {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.5.1", override: true},
       {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.5.1", override: true},
       {:esasl, github: "emqx/esasl", tag: "0.2.0"},
       {:esasl, github: "emqx/esasl", tag: "0.2.0"},
       {:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"},
       {:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"},

+ 1 - 1
rebar.config

@@ -67,7 +67,7 @@
     , {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
     , {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
     , {getopt, "1.0.2"}
     , {getopt, "1.0.2"}
     , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.0"}}}
     , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.0"}}}
-    , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.28.3"}}}
+    , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.29.0"}}}
     , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.1"}}}
     , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.1"}}}
     , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}}
     , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}}
     , {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}}
     , {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}}