fix: don't save cert/authz zip on disk when emqx start
This commit is contained in:
parent
4cc13c4aa5
commit
9b37837c9c
|
@ -62,10 +62,11 @@ sync_data_from_node() ->
|
||||||
TargetDirs = lists:filter(fun(Type) -> filelib:is_dir(filename:join(Dir, Type)) end, [
|
TargetDirs = lists:filter(fun(Type) -> filelib:is_dir(filename:join(Dir, Type)) end, [
|
||||||
"authz", "certs"
|
"authz", "certs"
|
||||||
]),
|
]),
|
||||||
{ok, Zip} = zip:zip(atom_to_list(node()) ++ "_data.zip", TargetDirs, [{cwd, Dir}]),
|
Name = "data.zip",
|
||||||
Res = {ok, _Bin} = file:read_file(Zip),
|
case zip:zip(Name, TargetDirs, [memory, {cwd, Dir}]) of
|
||||||
_ = file:delete(Zip),
|
{ok, {Name, Bin}} -> {ok, Bin};
|
||||||
Res.
|
{error, Reason} -> {error, Reason}
|
||||||
|
end.
|
||||||
|
|
||||||
%% ------------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
@ -195,8 +196,12 @@ conf_sort({ok, _}, {ok, _}) ->
|
||||||
sync_data_from_node(Node) ->
|
sync_data_from_node(Node) ->
|
||||||
case emqx_conf_proto_v2:sync_data_from_node(Node) of
|
case emqx_conf_proto_v2:sync_data_from_node(Node) of
|
||||||
{ok, DataBin} ->
|
{ok, DataBin} ->
|
||||||
{ok, Files} = zip:unzip(DataBin, [{cwd, emqx:data_dir()}]),
|
case zip:unzip(DataBin, [{cwd, emqx:data_dir()}]) of
|
||||||
?SLOG(debug, #{node => Node, msg => "sync_data_from_node_ok", files => Files}),
|
{ok, []} ->
|
||||||
|
?SLOG(debug, #{node => Node, msg => "sync_data_from_node_ignore"});
|
||||||
|
{ok, Files} ->
|
||||||
|
?SLOG(debug, #{node => Node, msg => "sync_data_from_node_ok", files => Files})
|
||||||
|
end,
|
||||||
ok;
|
ok;
|
||||||
Error ->
|
Error ->
|
||||||
?SLOG(emergency, #{node => Node, msg => "sync_data_from_node_failed", reason => Error}),
|
?SLOG(emergency, #{node => Node, msg => "sync_data_from_node_failed", reason => Error}),
|
||||||
|
|
Loading…
Reference in New Issue