fix(statsd): update config in cluster
This commit is contained in:
parent
888e7fd727
commit
3a38e8d68d
|
@ -94,7 +94,7 @@ terminate(_Reason, #state{estatsd_pid = Pid}) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Internale function
|
%% Internal function
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
trans_metrics_name(Name) ->
|
trans_metrics_name(Name) ->
|
||||||
Name0 = atom_to_binary(Name, utf8),
|
Name0 = atom_to_binary(Name, utf8),
|
||||||
|
|
|
@ -55,13 +55,19 @@ statsd(get, _Params) ->
|
||||||
{200, emqx:get_raw_config([<<"statsd">>], #{})};
|
{200, emqx:get_raw_config([<<"statsd">>], #{})};
|
||||||
|
|
||||||
statsd(put, #{body := Body}) ->
|
statsd(put, #{body := Body}) ->
|
||||||
{ok, Config} = emqx:update_config([statsd], Body),
|
case emqx:update_config([statsd],
|
||||||
|
Body,
|
||||||
|
#{rawconf_with_defaults => true, override_to => cluster}) of
|
||||||
|
{ok, #{raw_config := NewConfig, config := Config}} ->
|
||||||
case maps:get(<<"enable">>, Body) of
|
case maps:get(<<"enable">>, Body) of
|
||||||
true ->
|
true ->
|
||||||
_ = emqx_statsd_sup:stop_child(?APP),
|
_ = emqx_statsd_sup:stop_child(?APP),
|
||||||
emqx_statsd_sup:start_child(?APP, maps:get(config, Config));
|
emqx_statsd_sup:start_child(?APP, maps:get(config, Config));
|
||||||
false ->
|
false ->
|
||||||
_ = emqx_statsd_sup:stop_child(?APP),
|
_ = emqx_statsd_sup:stop_child(?APP)
|
||||||
ok
|
|
||||||
end,
|
end,
|
||||||
{200, emqx:get_raw_config([<<"statsd">>], #{})}.
|
{200, NewConfig};
|
||||||
|
{error, Reason} ->
|
||||||
|
Message = list_to_binary(io_lib:format("Update config failed ~p", [Reason])),
|
||||||
|
{500, 'INTERNAL_ERROR', Message}
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue