erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

provide eval command for nodetool and start script #461

Closed djnym closed 8 years ago

djnym commented 8 years ago

While rpc and rpcterms are decent they don't quite have the functionality I would like which is executing arbitrary calls against the running node. This adds an 'eval' command to the extended start script which calls nodetool. With it you can do things like

% myrel eval 'node()'
'myrel@dev'
% myrel eval 'io:format("~s\n",[[<<"hello">>,$\s,"world"]]).'
hello world
ok
% bin/myrel eval 'AppVersion = fun (App) -> [ {A, V} || {A,_,V} <- application:which_applications(), A =:= App ] end, [ AppVersion (A) || A <- [kernel, myrel ]]'
[[{kernel,"2.16.4"}],[{myrel,"0.1.0"}]]

While these examples are contrived, you can basically use this to run arbitrary code on the running node which is useful for troubleshooting, and system inspection.