summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-11-24 16:51:28 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-11-24 16:51:28 +0000
commit6de4d8441b3cad3b30f737fb20dc2d9c72adc6ae (patch)
treea6734bba9ed877a3eaeeed42bb7bed58287a0eef
parentf8bb22faff3fefc47c0dcc434117837e49d0c301 (diff)
downloadrabbitmq-server-6de4d8441b3cad3b30f737fb20dc2d9c72adc6ae.tar.gz
Basic rabbitmqctl eval, with let-it-crash error handling.
-rw-r--r--docs/rabbitmqctl.1.xml16
-rw-r--r--src/rabbit_control.erl7
2 files changed, 23 insertions, 0 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml
index f21888bd..15755038 100644
--- a/docs/rabbitmqctl.1.xml
+++ b/docs/rabbitmqctl.1.xml
@@ -1315,6 +1315,22 @@
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><cmdsynopsis><command>eval</command> <arg choice="req"><replaceable>expr</replaceable></arg></cmdsynopsis></term>
+ <listitem>
+ <para>
+ Evaluate an arbitrary Erlang expression.
+ </para>
+ <para role="example-prefix">
+ For example:
+ </para>
+ <screen role="example">rabbitmqctl eval 'node().'</screen>
+ <para role="example">
+ This command returns the name of the node to which rabbitmqctl has connected.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect2>
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index fa8dd262..9d47a78f 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -368,6 +368,13 @@ action(report, Node, _Args, _Opts, Inform) ->
[print_report(Node, Q) || Q <- ?GLOBAL_QUERIES],
[print_report(Node, Q, [V]) || Q <- ?VHOST_QUERIES, V <- VHosts],
io:format("End of server status report~n"),
+ ok;
+
+action(eval, Node, [Expr], _Opts, _Inform) ->
+ {ok, Scanned, _} = erl_scan:string(Expr),
+ {ok, Parsed} = erl_parse:parse_exprs(Scanned),
+ {value, Value, _Bindings} = rpc_call(Node, erl_eval, exprs, [Parsed, []]),
+ io:format("~p~n", [Value]),
ok.
%%----------------------------------------------------------------------------