summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@rabbitmq.com>2014-06-23 15:38:25 +0400
committerMichael Klishin <michael@rabbitmq.com>2014-06-23 15:38:25 +0400
commitd5c76cf267cb1988f999d9c1a51d4f3dcbc0b747 (patch)
tree999b5c4b02f36247cea38c47da7924ce8473a9ad
parent6809383c13429daa5f5e5c86503c7e8f49b3189c (diff)
downloadrabbitmq-server-d5c76cf267cb1988f999d9c1a51d4f3dcbc0b747.tar.gz
Improve error messages from rabbitmqctl when the rabbit app is stopped
-rw-r--r--src/rabbit_control_main.erl33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 451f4d70..88b288b4 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -188,7 +188,12 @@ start() ->
print_error("~s", [Reason]),
rabbit_misc:quit(2);
{badrpc, {'EXIT', Reason}} ->
- print_error("~p", [Reason]),
+ case Reason of
+ {noproc, Cause} ->
+ print_noproc_diagnostics(Command, Node, Cause);
+ _ ->
+ print_error("~p", [Reason])
+ end,
rabbit_misc:quit(2);
{badrpc, Reason} ->
print_error("unable to connect to node ~w: ~w", [Node, Reason]),
@@ -203,7 +208,11 @@ start() ->
rabbit_misc:quit(2)
end.
-fmt_stderr(Format, Args) -> rabbit_misc:format_stderr(Format ++ "~n", Args).
+
+fmt_stderr(Format) ->
+ rabbit_misc:format_stderr(Format ++ "~n", []).
+fmt_stderr(Format, Args) ->
+ rabbit_misc:format_stderr(Format ++ "~n", Args).
print_report(Node, {Descr, Module, InfoFun, KeysFun}) ->
io:format("~s:~n", [Descr]),
@@ -227,6 +236,26 @@ print_error(Format, Args) -> fmt_stderr("Error: " ++ Format, Args).
print_badrpc_diagnostics(Nodes) ->
fmt_stderr(rabbit_nodes:diagnostics(Nodes), []).
+print_noproc_diagnostics(Command, Node, Reason) ->
+ fmt_stderr("unable to execute ~s on node ~s", [Command, Node]),
+ fmt_stderr("~nDIAGNOSTICS~n===========~n"),
+ case rpc:call(Node, application, which_applications, [5000]) of
+ {badrpc, _Reason} ->
+ fmt_stderr("unable to execute ~s on node ~s, "
+ "check that the rabbit app is running~n~n",
+ [Command, Node]);
+ Apps ->
+ S = case proplists:is_defined(rabbit, Apps) of
+ true ->
+ "is";
+ false ->
+ "is not"
+ end,
+ fmt_stderr("rabbit app on node ~s ~s running~n",
+ [Node, S])
+ end,
+ print_error("~p", [Reason]).
+
stop() ->
ok.