Просмотр исходного кода

fix(docker): cannot set log_level using os env

Shawn 4 лет назад
Родитель
Сommit
c9cf8b66e7

+ 4 - 4
.ci/docker-compose-file/conf.cluster.env

@@ -1,7 +1,7 @@
 EMQX_NAME=emqx
 EMQX_CLUSTER__DISCOVERY_STRATEGY=static
 EMQX_CLUSTER__STATIC__SEEDS="[emqx@node1.emqx.io, emqx@node2.emqx.io]"
-EMQX_LISTENER__TCP__EXTERNAL__PROXY_PROTOCOL=on
-EMQX_LISTENER__WS__EXTERNAL__PROXY_PROTOCOL=on
-EMQX_LOG__LEVEL=debug
-EMQX_LOADED_PLUGINS=emqx_sn
+EMQX_ZONES__DEFAULT__LISTENERS__MQTT_TCP__PROXY_PROTOCOL=true
+EMQX_ZONES__DEFAULT__LISTENERS__MQTT_WS__PROXY_PROTOCOL=true
+EMQX_LOG__CONSOLE_HANDLER__ENABLE=true
+EMQX_LOG__PRIMARY_LEVEL=debug

+ 1 - 1
apps/emqx/etc/emqx.conf

@@ -325,7 +325,7 @@ log {
   ## Note: Only the messages with severity level higher than or
   ## equal to this level will be logged.
   ##
-  ## @doc log.level
+  ## @doc log.primary_level
   ## ValueType: debug | info | notice | warning | error | critical | alert | emergency
   ## Default: warning
   primary_level: warning

+ 14 - 5
apps/emqx/src/emqx_schema.erl

@@ -506,7 +506,7 @@ fields("alarm") ->
     ];
 
 fields(ExtraField) ->
-    Mod = list_to_atom(ExtraField++"_schema"),
+    Mod = to_atom(ExtraField++"_schema"),
     Mod:fields(ExtraField).
 
 mqtt_listener() ->
@@ -649,7 +649,7 @@ filter(Opts) ->
 %%  , {"server_name_indication", undefined, undefined)}
 %%  ...]
 ssl(Defaults) ->
-    D = fun (Field) -> maps:get(list_to_atom(Field), Defaults, undefined) end,
+    D = fun (Field) -> maps:get(to_atom(Field), Defaults, undefined) end,
     [ {"enable", t(boolean(), undefined, D("enable"))}
     , {"cacertfile", t(string(), undefined, D("cacertfile"))}
     , {"certfile", t(string(), undefined, D("certfile"))}
@@ -793,7 +793,7 @@ to_comma_separated_list(Str) ->
     {ok, string:tokens(Str, ", ")}.
 
 to_comma_separated_atoms(Str) ->
-    {ok, lists:map(fun list_to_atom/1, string:tokens(Str, ", "))}.
+    {ok, lists:map(fun to_atom/1, string:tokens(Str, ", "))}.
 
 to_bar_separated_list(Str) ->
     {ok, string:tokens(Str, "| ")}.
@@ -815,7 +815,7 @@ to_erl_cipher_suite(Str) ->
     end.
 
 options(static, Conf) ->
-    [{seeds, [list_to_atom(S) || S <- conf_get("cluster.static.seeds", Conf, [])]}];
+    [{seeds, [to_atom(S) || S <- conf_get("cluster.static.seeds", Conf, [])]}];
 options(mcast, Conf) ->
     {ok, Addr} = inet:parse_address(conf_get("cluster.mcast.addr", Conf)),
     {ok, Iface} = inet:parse_address(conf_get("cluster.mcast.iface", Conf)),
@@ -830,7 +830,7 @@ options(etcd, Conf) ->
     Namespace = "cluster.etcd.ssl",
     SslOpts = fun(C) ->
         Options = keys(Namespace, C),
-        lists:map(fun(Key) -> {list_to_atom(Key), conf_get([Namespace, Key], Conf)} end, Options) end,
+        lists:map(fun(Key) -> {to_atom(Key), conf_get([Namespace, Key], Conf)} end, Options) end,
     [{server, conf_get("cluster.etcd.server", Conf)},
      {prefix, conf_get("cluster.etcd.prefix", Conf, "emqxcl")},
      {node_ttl, conf_get("cluster.etcd.node_ttl", Conf, 60)},
@@ -844,3 +844,12 @@ options(k8s, Conf) ->
      {suffix, conf_get("cluster.k8s.suffix", Conf, "")}];
 options(manual, _Conf) ->
     [].
+
+to_atom(#{value := Val}= _RichMap) ->
+    to_atom(Val);
+to_atom(Atom) when is_atom(Atom) ->
+    Atom;
+to_atom(Str) when is_list(Str) ->
+    list_to_atom(Str);
+to_atom(Bin) when is_binary(Bin) ->
+    list_to_atom(binary_to_list(Bin)).

+ 2 - 2
deploy/docker/README.md

@@ -214,7 +214,7 @@ Let's create a static node list cluster from docker-compose.
       - "EMQX_NAME=emqx"
       - "EMQX_HOST=node1.emqx.io"
       - "EMQX_CLUSTER__DISCOVERY_STRATEGY=static"
-      - "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
+      - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io, emqx@node2.emqx.io]"
       networks:
         emqx-bridge:
           aliases:
@@ -226,7 +226,7 @@ Let's create a static node list cluster from docker-compose.
       - "EMQX_NAME=emqx"
       - "EMQX_HOST=node2.emqx.io"
       - "EMQX_CLUSTER__DISCOVERY_STRATEGY=static"
-      - "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
+      - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io, emqx@node2.emqx.io]"
       networks:
         emqx-bridge:
           aliases: