|
|
@@ -850,7 +850,7 @@ end}.
|
|
|
%% of queued MQTT messages of QoS 1 and 2.
|
|
|
%% Zero or negative is to disable.
|
|
|
{mapping, "zone.$name.force_shutdown_policy", "emqx.zones", [
|
|
|
- {default, "0 | 0MB"},
|
|
|
+ {default, "default"},
|
|
|
{datatype, string}
|
|
|
]}.
|
|
|
|
|
|
@@ -899,15 +899,34 @@ end}.
|
|
|
count => list_to_integer(Count)}
|
|
|
end,
|
|
|
{force_gc_policy, GcPolicy};
|
|
|
+ ("force_shutdown_policy", "default") ->
|
|
|
+ {DefaultLen, DefaultSiz} =
|
|
|
+ case erlang:system_info(wordsize) of
|
|
|
+ 8 -> % arch_64
|
|
|
+ {8000, cuttlefish_bytesize:parse("800MB")};
|
|
|
+ 4 -> % arch_32
|
|
|
+ {1000, cuttlefish_bytesize:parse("100MB")}
|
|
|
+ end,
|
|
|
+ {force_shutdown_policy, #{message_queue_len => DefaultLen,
|
|
|
+ max_heap_size => DefaultSiz}};
|
|
|
("force_shutdown_policy", Val) ->
|
|
|
[Len, Siz] = string:tokens(Val, "| "),
|
|
|
- ShutdownPolicy = case cuttlefish_bytesize:parse(Siz) of
|
|
|
- {error, Reason} ->
|
|
|
- error(Reason);
|
|
|
- Siz1 ->
|
|
|
- #{message_queue_len => list_to_integer(Len),
|
|
|
- max_heap_size => Siz1}
|
|
|
- end,
|
|
|
+ MaxSiz = case erlang:system_info(wordsize) of
|
|
|
+ 8 -> % arch_64
|
|
|
+ (1 bsl 59) - 1;
|
|
|
+ 4 -> % arch_32
|
|
|
+ (1 bsl 27) - 1
|
|
|
+ end,
|
|
|
+ ShutdownPolicy =
|
|
|
+ case cuttlefish_bytesize:parse(Siz) of
|
|
|
+ {error, Reason} ->
|
|
|
+ error(Reason);
|
|
|
+ Siz1 when Siz1 > MaxSiz ->
|
|
|
+ cuttlefish:invalid(io_lib:format("force_shutdown_policy: heap-size ~s is too large", [Siz]));
|
|
|
+ Siz1 ->
|
|
|
+ #{message_queue_len => list_to_integer(Len),
|
|
|
+ max_heap_size => Siz1}
|
|
|
+ end,
|
|
|
{force_shutdown_policy, ShutdownPolicy};
|
|
|
("mqueue_priorities", Val) ->
|
|
|
case Val of
|