summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-07-14 13:29:27 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2016-07-14 13:39:17 +0300
commitd14f8647d92c866ab384c3fffaea405ffb77c354 (patch)
tree4b87d3cdd027f3eded2cc80ca64baaa17a562791
parent7b36b7ff75d5d7cea98b40690fd7b19c983b9c5c (diff)
downloadrabbitmq-server-git-d14f8647d92c866ab384c3fffaea405ffb77c354.tar.gz
Reuse timeout/error logic for `node_health_check`
-rw-r--r--src/rabbit_control_main.erl28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 55839d34e0..d2f0e8bcb0 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -114,14 +114,15 @@
[stop, stop_app, start_app, wait, reset, force_reset, rotate_logs,
join_cluster, change_cluster_node_type, update_cluster_nodes,
forget_cluster_node, rename_cluster_node, cluster_status, status,
- environment, eval, force_boot, help, node_health_check, hipe_compile]).
+ environment, eval, force_boot, help, hipe_compile]).
%% [Command | {Command, DefaultTimeoutInMilliSeconds}]
-define(COMMANDS_WITH_TIMEOUT,
[list_user_permissions, list_policies, list_queues, list_exchanges,
list_bindings, list_connections, list_channels, list_consumers,
list_vhosts, list_parameters,
- purge_queue]).
+ purge_queue,
+ {node_health_check, 70000}]).
%%----------------------------------------------------------------------------
@@ -578,17 +579,6 @@ action(eval, Node, [Expr], _Opts, _Inform) ->
action(help, _Node, _Args, _Opts, _Inform) ->
io:format("~s", [rabbit_ctl_usage:usage()]);
-action(node_health_check, Node, _Args, _Opts, Inform) ->
- Inform("Checking health of node ~p", [Node]),
- try
- rabbit_health_check:node(Node),
- io:format("Health check passed~n")
- catch
- {node_is_ko, ErrorMsg, ErrorCode} ->
- io:format("Heath check failed:~n~s~n", [ErrorMsg]),
- halt(ErrorCode)
- end;
-
action(Command, Node, Args, Opts, Inform) ->
%% For backward compatibility, run commands accepting a timeout with
%% the default timeout.
@@ -682,7 +672,17 @@ action(list_consumers, Node, _Args, Opts, Inform, Timeout) ->
Inform("Listing consumers", []),
VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
call(Node, {rabbit_amqqueue, consumers_all, [VHostArg]},
- rabbit_amqqueue:consumer_info_keys(), Timeout).
+ rabbit_amqqueue:consumer_info_keys(), Timeout);
+
+action(node_health_check, Node, _Args, _Opts, Inform, Timeout) ->
+ Inform("Checking health of node ~p", [Node]),
+ case rabbit_health_check:node(Node, Timeout) of
+ ok ->
+ io:format("Health check passed~n"),
+ ok;
+ Other ->
+ Other
+ end.
format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)).