fix(prometheus): stop app with error check & dialyzer

This commit is contained in:
DDDHuang 2022-01-05 15:59:17 +08:00
parent 72713cb85f
commit 31aed3ea8e
2 changed files with 22 additions and 19 deletions

View File

@ -95,18 +95,21 @@ do_start() ->
emqx_prometheus_sup:start_child(?APP, emqx_conf:get([prometheus])).
do_stop() ->
emqx_prometheus_sup:stop_child(?APP).
do_restart() ->
case {stop(), start()} of
{ok, ok} ->
case emqx_prometheus_sup:stop_child(?APP) of
ok ->
ok;
{Error1, Error2} ->
?LOG(error, "~p restart failed stop: ~p start: ~p", [?MODULE, Error1, Error2])
{error, not_found} ->
ok
end.
do_restart() ->
ok = do_start(),
ok = do_stop(),
ok.
cluster_call(F, A) ->
[ok = rpc_call(N, F, A) || N <- mria_mnesia:running_nodes()].
[ok = rpc_call(N, F, A) || N <- mria_mnesia:running_nodes()],
ok.
rpc_call(N, F, A) ->
case rpc:call(N, ?MODULE, F, A, 5000) of

View File

@ -61,10 +61,12 @@ update(Config) ->
Config,
#{rawconf_with_defaults => true, override_to => cluster}) of
{ok, #{raw_config := NewConfigRows}} ->
start(),
case maps:get(<<"enable">>, Config) of
true -> stop();
false -> ok
_ = start(),
case maps:get(<<"enable">>, Config, true) of
true ->
ok = stop();
false ->
ignore
end,
{ok, NewConfigRows};
{error, Reason} ->
@ -83,15 +85,13 @@ do_stop() ->
emqx_statsd_sup:ensure_child_stopped(?APP).
do_restart() ->
case {stop(), start()} of
{ok, ok} ->
ok;
{Error1, Error2} ->
?LOG(error, "~p restart failed stop: ~p start: ~p", [?MODULE, Error1, Error2])
end.
ok = do_start(),
ok = do_stop(),
ok.
cluster_call(F, A) ->
[ok = rpc_call(N, F, A) || N <- mria_mnesia:running_nodes()].
[ok = rpc_call(N, F, A) || N <- mria_mnesia:running_nodes()],
ok.
rpc_call(N, F, A) ->
case rpc:call(N, ?MODULE, F, A, 5000) of