summaryrefslogtreecommitdiff
path: root/priv/templates/simplenode.nodetool
diff options
context:
space:
mode:
authorRoberto Aloi <robert.aloi@klarna.com>2014-10-20 09:40:43 +0200
committerRoberto Aloi <robert.aloi@klarna.com>2014-10-21 14:22:37 +0200
commit93ccbf936c6a5e4f6882a2811ae32e9e799683bc (patch)
tree17446f38e80006c406e873b1cdf4d5f1f9b6cf9b /priv/templates/simplenode.nodetool
parentb693c23663bbd9f9522b7f5fc0337ef7cee5557a (diff)
downloadrebar-93ccbf936c6a5e4f6882a2811ae32e9e799683bc.tar.gz
Implement eval command via nodetool
Diffstat (limited to 'priv/templates/simplenode.nodetool')
-rwxr-xr-xpriv/templates/simplenode.nodetool21
1 files changed, 20 insertions, 1 deletions
diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool
index ce06c6a..7ae8a27 100755
--- a/priv/templates/simplenode.nodetool
+++ b/priv/templates/simplenode.nodetool
@@ -95,9 +95,23 @@ main(Args) ->
Other ->
io:format("~p\n", [Other])
end;
+ ["eval", Str0] ->
+ Str = string:strip(Str0, right, $.) ++ ".",
+ Bindings = erl_eval:new_bindings(),
+ case rpc:call(TargetNode,
+ erl_eval,
+ exprs,
+ [parse(Str), Bindings],
+ 60000) of
+ {badrpc, Reason} ->
+ io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
+ halt(1);
+ {value, Value, _Bindings} ->
+ io:format("~p\n", [Value])
+ end;
Other ->
io:format("Other: ~p\n", [Other]),
- io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n")
+ io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms|eval}\n")
end,
net_kernel:stop().
@@ -180,3 +194,8 @@ consult(Cont, Str, Acc) ->
{more, Cont1} ->
consult(Cont1, eof, Acc)
end.
+
+parse(Str) ->
+ {ok, Tokens, _} = erl_scan:string(Str),
+ {ok, Exprs} = erl_parse:parse_exprs(Tokens),
+ Exprs.