mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Synchronize nodetool escript with riak version
This commit is contained in:
parent
0c191a5a60
commit
6ce2beebd0
1 changed files with 36 additions and 1 deletions
|
@ -30,7 +30,8 @@ main(Args) ->
|
||||||
["reboot"] ->
|
["reboot"] ->
|
||||||
io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]);
|
io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]);
|
||||||
["rpc", Module, Function | RpcArgs] ->
|
["rpc", Module, Function | RpcArgs] ->
|
||||||
case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], 60000) of
|
case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function),
|
||||||
|
[RpcArgs], 60000) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
|
@ -39,6 +40,15 @@ main(Args) ->
|
||||||
_ ->
|
_ ->
|
||||||
halt(1)
|
halt(1)
|
||||||
end;
|
end;
|
||||||
|
["rpcterms", Module, Function, ArgsAsString] ->
|
||||||
|
case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function),
|
||||||
|
consult(ArgsAsString), 60000) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
|
||||||
|
halt(1);
|
||||||
|
Other ->
|
||||||
|
io:format("~p\n", [Other])
|
||||||
|
end;
|
||||||
Other ->
|
Other ->
|
||||||
io:format("Other: ~p\n", [Other]),
|
io:format("Other: ~p\n", [Other]),
|
||||||
io:format("Usage: nodetool {ping|stop|restart|reboot}\n")
|
io:format("Usage: nodetool {ping|stop|restart|reboot}\n")
|
||||||
|
@ -78,3 +88,28 @@ append_node_suffix(Name, Suffix) ->
|
||||||
[Node] ->
|
[Node] ->
|
||||||
list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
|
list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
%%
|
||||||
|
%% Given a string or binary, parse it into a list of terms, ala file:consult/0
|
||||||
|
%%
|
||||||
|
consult(Str) when is_list(Str) ->
|
||||||
|
consult([], Str, []);
|
||||||
|
consult(Bin) when is_binary(Bin)->
|
||||||
|
consult([], binary_to_list(Bin), []).
|
||||||
|
|
||||||
|
consult(Cont, Str, Acc) ->
|
||||||
|
case erl_scan:tokens(Cont, Str, 0) of
|
||||||
|
{done, Result, Remaining} ->
|
||||||
|
case Result of
|
||||||
|
{ok, Tokens, _} ->
|
||||||
|
{ok, Term} = erl_parse:parse_term(Tokens),
|
||||||
|
consult([], Remaining, [Term | Acc]);
|
||||||
|
{eof, _Other} ->
|
||||||
|
lists:reverse(Acc);
|
||||||
|
{error, Info, _} ->
|
||||||
|
{error, Info}
|
||||||
|
end;
|
||||||
|
{more, Cont1} ->
|
||||||
|
consult(Cont1, eof, Acc)
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in a new issue