Use '0MB' to configure size of force_shutdown_policy

This commit is contained in:
Feng Lee 2018-09-22 06:14:43 +08:00 committed by GitHub
parent 29787d8945
commit 05a5ad0f8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -839,7 +839,7 @@ end}.
%% Total heap size is the in Erlang 'words' not in 'bytes'. %% Total heap size is the in Erlang 'words' not in 'bytes'.
%% Zero or negative is to disable. %% Zero or negative is to disable.
{mapping, "zone.$name.force_shutdown_policy", "emqx.zones", [ {mapping, "zone.$name.force_shutdown_policy", "emqx.zones", [
{default, "0 | 0"}, {default, "0 | 0MB"},
{datatype, string} {datatype, string}
]}. ]}.
@ -856,8 +856,14 @@ end}.
bytes => list_to_integer(Bytes)}}; bytes => list_to_integer(Bytes)}};
("force_shutdown_policy", Val) -> ("force_shutdown_policy", Val) ->
[Len, Siz] = string:tokens(Val, "| "), [Len, Siz] = string:tokens(Val, "| "),
{force_shutdown_policy, #{message_queue_len => list_to_integer(Len), ShutdownPolicy = case cuttlefish_bytesize:parse(Siz) of
total_heap_size => list_to_integer(Siz)}}; {error, Reason} ->
error(Reason);
Siz1 ->
#{message_queue_len => list_to_integer(Len),
total_heap_size => Siz1}
end,
{force_shutdown_policy, ShutdownPolicy};
(Opt, Val) -> (Opt, Val) ->
{list_to_atom(Opt), Val} {list_to_atom(Opt), Val}
end, end,