diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_control_main.erl | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 92712da9da..4f5a766cf4 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -145,19 +145,6 @@ start() -> end, Quiet = proplists:get_bool(?QUIET_OPT, Opts), Node = proplists:get_value(?NODE_OPT, Opts), - case lists:member(Command, ?COMMANDS_NOT_REQUIRING_APP) of - false -> - ensure_app_running(Node); - true -> - ok; - {badrpc, {'EXIT', Err}} -> - print_error("~p", [Err]), - rabbit_misc:quit(2); - {badrpc, Err} -> - print_error("unable to connect to node ~w: ~w", [Node, Err]), - print_badrpc_diagnostics([Node]), - rabbit_misc:quit(2) - end, Inform = case Quiet of true -> fun (_Format, _Args1) -> ok end; false -> fun (Format, Args1) -> @@ -172,7 +159,7 @@ start() -> %% The reason we don't use a try/catch here is that rpc:call turns %% thrown errors into normal return values - case catch action(Command, Node, Args, Opts, Inform) of + case catch do_action(Command, Node, Args, Opts, Inform) of ok -> case Quiet of true -> ok; @@ -267,6 +254,15 @@ parse_arguments(CmdLine, NodeStr) -> %%---------------------------------------------------------------------------- +do_action(Command, Node, Args, Opts, Inform) -> + case lists:member(Command, ?COMMANDS_NOT_REQUIRING_APP) of + false -> case ensure_app_running(Node) of + ok -> action(Command, Node, Args, Opts, Inform); + E -> E + end; + true -> action(Command, Node, Args, Opts, Inform) + end. + action(stop, Node, Args, _Opts, Inform) -> Inform("Stopping and halting node ~p", [Node]), Res = call(Node, {rabbit, stop_and_halt, []}), |
