3

Folks we are now delploying a lot of Erlang instances and we are seeing bugs been thrown and would like to examine them...

Normally we connect to the running instance with a remote shell and get access to an Erlang console that way, but this doesn't work for rb or error messages...

How do I get remote access to my SASL error messages without dropping the server, starting it non-detached and looking at the shell?

Gordon Guthrie
  • 6,252
  • 2
  • 27
  • 52

3 Answers3

4

I ran into this back in R11B and ended up creating a clone of rb that works over a remote shell (http://github.com/archaelus/erms/blob/master/src/erms_rb.erl). The trick is to discover the group_leader of the caller and then send output there.

I should probably tidy that up and submit it as a patch to rb.

archaelus
  • 7,109
  • 26
  • 37
2

I start my remote shell via -remsh (${ROOTDIR}/bin/erl -name shell@${NODE_IP} -remsh ${NODE_NAME}). once there I set the rb_server group_leader to the current group_leader of the shell and rb henceforth prints its output to the active shell:

(cacherl@192.168.2.31)1> rb:start().
{ok,<0.213.0>}
(cacherl@192.168.2.31)2> group_leader(group_leader(),erlang:whereis(rb_server)).
true
(cacherl@192.168.2.31)3> rb:show(1).

PROGRESS REPORT  <0.77.0>                                   2011-01-28 17:49:23
===============================================================================
supervisor                                                     {local,sasl_sup}
started
         [{pid,<4543.96.0>},
         {name,rb_server},
         {mfargs,{rb,start_link,[[]]}},
         {restart_type,temporary},
         {shutdown,brutal_kill},
         {child_type,worker}]

ok
(cacherl@192.168.2.31)4> 

EDIT: encapsulate it in a function for convenience:

%% @doc Start the report browser and reset its group-leader. 
%% For use in a remote shell
start_remote_rb() ->
    {ok, Pid} = rb:start(),
    true = erlang:group_leader(erlang:group_leader(), Pid),
    ok.

regards, Tom

Tom Regner
  • 6,856
  • 4
  • 32
  • 47
  • Cheers Tom. I asked this question so long ago that I can no longer remember how we do it. I think we use Archaelus patched RB server :( – Gordon Guthrie Jan 30 '11 at 11:17
  • Yeah I figured as much, but I thought I add it here nonetheless, so that the next guy searching will also find this method. – Tom Regner Feb 02 '11 at 08:20
1

I haven't used rb, so I don't know much about it, but maybe this will help you anyway:

You can set SASLs error report handler to write to disk, see http://www.erlang.org/doc/man/sasl_app.html :

sasl_error_logger = Value <optional>

Value is one of:

...

{file,FileName}

Installs sasl_report_file_h in the error logger. This makes all reports go to the file FileName. FileName is a string.

...

I also dimly remember there being a way to install a custom handler callback, but I can't seem to find it right now, unfortunately.