Skip to content

Commit d14f864

Browse files
author
Alexey Lebedeff
committed
Reuse timeout/error logic for node_health_check
1 parent 7b36b7f commit d14f864

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/rabbit_control_main.erl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@
114114
[stop, stop_app, start_app, wait, reset, force_reset, rotate_logs,
115115
join_cluster, change_cluster_node_type, update_cluster_nodes,
116116
forget_cluster_node, rename_cluster_node, cluster_status, status,
117-
environment, eval, force_boot, help, node_health_check, hipe_compile]).
117+
environment, eval, force_boot, help, hipe_compile]).
118118

119119
%% [Command | {Command, DefaultTimeoutInMilliSeconds}]
120120
-define(COMMANDS_WITH_TIMEOUT,
121121
[list_user_permissions, list_policies, list_queues, list_exchanges,
122122
list_bindings, list_connections, list_channels, list_consumers,
123123
list_vhosts, list_parameters,
124-
purge_queue]).
124+
purge_queue,
125+
{node_health_check, 70000}]).
125126

126127
%%----------------------------------------------------------------------------
127128

@@ -578,17 +579,6 @@ action(eval, Node, [Expr], _Opts, _Inform) ->
578579
action(help, _Node, _Args, _Opts, _Inform) ->
579580
io:format("~s", [rabbit_ctl_usage:usage()]);
580581

581-
action(node_health_check, Node, _Args, _Opts, Inform) ->
582-
Inform("Checking health of node ~p", [Node]),
583-
try
584-
rabbit_health_check:node(Node),
585-
io:format("Health check passed~n")
586-
catch
587-
{node_is_ko, ErrorMsg, ErrorCode} ->
588-
io:format("Heath check failed:~n~s~n", [ErrorMsg]),
589-
halt(ErrorCode)
590-
end;
591-
592582
action(Command, Node, Args, Opts, Inform) ->
593583
%% For backward compatibility, run commands accepting a timeout with
594584
%% the default timeout.
@@ -682,7 +672,17 @@ action(list_consumers, Node, _Args, Opts, Inform, Timeout) ->
682672
Inform("Listing consumers", []),
683673
VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
684674
call(Node, {rabbit_amqqueue, consumers_all, [VHostArg]},
685-
rabbit_amqqueue:consumer_info_keys(), Timeout).
675+
rabbit_amqqueue:consumer_info_keys(), Timeout);
676+
677+
action(node_health_check, Node, _Args, _Opts, Inform, Timeout) ->
678+
Inform("Checking health of node ~p", [Node]),
679+
case rabbit_health_check:node(Node, Timeout) of
680+
ok ->
681+
io:format("Health check passed~n"),
682+
ok;
683+
Other ->
684+
Other
685+
end.
686686

687687
format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)).
688688

0 commit comments

Comments
 (0)