Explorar o código

Merge pull request #5775 from zmstone/feat-save-override-config-in-pp-hocon-format

feat(config): save override config in hocon pretty-print format
Zaiming (Stone) Shi %!s(int64=4) %!d(string=hai) anos
pai
achega
f0e58d0c9b
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 2 2
      apps/emqx/src/emqx_config.erl
  2. 1 1
      apps/emqx/src/emqx_config_handler.erl

+ 2 - 2
apps/emqx/src/emqx_config.erl

@@ -355,7 +355,7 @@ save_to_override_conf(RawConf) ->
         undefined -> ok;
         FileName ->
             ok = filelib:ensure_dir(FileName),
-            case file:write_file(FileName, jsx:prettify(jsx:encode(RawConf))) of
+            case file:write_file(FileName, hocon_pp:do(RawConf, #{})) of
                 ok -> ok;
                 {error, Reason} ->
                     logger:error("write to ~s failed, ~p", [FileName, Reason]),
@@ -424,7 +424,7 @@ root_names_from_conf(RawConf) ->
     [Name || Name <- get_root_names(), lists:member(Name, Keys)].
 
 atom(Bin) when is_binary(Bin) ->
-    binary_to_existing_atom(Bin, latin1);
+    binary_to_existing_atom(Bin, utf8);
 atom(Str) when is_list(Str) ->
     list_to_existing_atom(Str);
 atom(Atom) when is_atom(Atom) ->

+ 1 - 1
apps/emqx/src/emqx_config_handler.erl

@@ -310,4 +310,4 @@ safe_atom(Bin) when is_binary(Bin) ->
 safe_atom(Str) when is_list(Str) ->
     list_to_existing_atom(Str);
 safe_atom(Atom) when is_atom(Atom) ->
-    Atom.
+    Atom.