diff options
| author | Tim Watson <watson.timothy@gmail.com> | 2014-03-17 21:08:47 +0000 |
|---|---|---|
| committer | Tim Watson <watson.timothy@gmail.com> | 2014-03-17 21:08:47 +0000 |
| commit | 09c1d873358fe0c1cf73ac974f9f54046e24667a (patch) | |
| tree | d7aeff69f1796c745c0d627f97127f03ec4e3a62 | |
| parent | 833d83ab86b55d7aa3fa7f80b31145e041d825c8 (diff) | |
| download | rabbitmq-server-git-09c1d873358fe0c1cf73ac974f9f54046e24667a.tar.gz | |
A slightly nicer (more explanatory) UI for rabbitmq-plugins
| -rw-r--r-- | src/rabbit_plugins_main.erl | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index c9d4b73fab..3976cc457b 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -326,12 +326,35 @@ action_change(Node, Action, Targets) -> rpc_call(Node, rabbit_plugins, Action, [Targets]). rpc_call(Node, Mod, Action, Args) -> - case rpc:call(Node, Mod, Action, Args, ?RPC_TIMEOUT) of - {badrpc, nodedown} -> io:format("Plugin configuration has changed.~n"); - ok -> io:format("Plugin(s) ~pd.~n", [Action]); - Error -> io:format("Unable to ~p plugin(s). " - "Please restart the broker " - "to apply your changes.~nError: ~p~n", - [Action, Error]) + case net_adm:ping(Node) of + pong -> io:format("Changing plugin configuration on ~p.", [Node]), + AsyncKey = rpc:async_call(Node, Mod, Action, Args), + rpc_progress(AsyncKey, Node, Action); + pang -> io:format("Plugin configuration has changed. " + "Plugins were not ~p since node is down.~n" + "Please start the broker to apply " + "your changes.~n", + [case Action of + enable -> started; + disable -> stopped + end]) + + end. + +rpc_progress(Key, Node, Action) -> + case rpc:nb_yield(Key, 100) of + timeout -> io:format("."), + rpc_progress(Key, Node, Action); + {value, {badrpc, nodedown}} -> + io:format(". error: Unable to contact ~p.~n ", [Node]), + io:format("Please start the broker to apply " + "your changes.~n"); + {value, ok} -> + io:format(". done: Plugin(s) ~pd.~n", [Action]); + {value, Error} -> + io:format(". error: Unable to ~p plugin(s).~n" + "Please restart the broker to apply your changes.~n" + "Error: ~p~n", + [Action, Error]) end. |
