Re: Question about connecting to a node and proposed patch

Matthias Radestock <[email protected]> Thu, 28 Jun 2007 06:01:46 +0100
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
Bill,

Bill Clementson <[email protected]> writes:

> Have you tried debugging the erl-check-backend call to determine why
> it's failing to load the distel beam files on the target node or do
> you have any clues as to why it's not working (other than the badrpc
> messages)?

I have only spent a short time debugging this problem. I have a
workaround (using .erlang) that works ok, and my elisp debugging skills
aren't strong enough to be confident I would be able to fix the issue in a
reasonable time. I'll give it another try though when I have a spare few
hours.

>> I use "C-c C-d n" for its documented purpose - to select "the nodename
>> to connect to in future.". So, for example, I often use the same node
>> for a long time and frequently restart it, and don't want to have to
>> think about / find out whether the node is up or down when typing "C-c
>> C-d n".
>
> But, since all "C-c C-d n" seems to do is change the current node that
> distel deals with and update the node name in the mode line [...]

Correct. And that is all it is supposed to do. I want to keep it that
way.

> However, I agree that my patch doesn't deal with nodes that are
> bumped/restarted.

That is a major regression. Not from the current state of affairs,
obviously, but from the original design and how things work when not
using the new auto code-loading feature.

>> As a stop-gap solution, may I suggest another key-bound command
>> "erl-ping" which executes the erl-spawn call from your patch on
>> (erl-target-node), i.e. it will work like most other distel commands by
>> prompting for a node if none is currently selected and performing the
>> action (in this case a call to erlang:node()) on it. 
>
> I dislike having a separate "erl-ping" function as it is something
> that one has to manually do (and know when to do it).

You can invoke that command *instead* of "C-c C-d n" in order to connect
(rather than just select) the first time, and subsequently reconnect
after node bounces. This isn't any more manual than what you currently
do; it's just a different command.

To let us switch nodes, we make the command prompt us for a node name
when invoked with a prefix argument (C-u ...) - something I wish all
distel commands did. Give this code a try:

(defun erl-ping (node)
  "Ping the NODE, uploading distel code as a side effect."
  (interactive (list (if current-prefix-arg
                         (erl-choose-nodename)
                       (erl-target-node))))
  (erl-spawn
    (erl-send-rpc node 'erlang 'node nil)
    (erl-receive (node)
	((['rex response]
          (if (equal node response)
              (message "Successfully communicated with remote node %S"
                       node)
            (message "Failed to communicate with node %S: %S"
                     node response)))))))

So, to connect and reconnect just run 'M-x erl-ping'. To switch nodes
(and connect) run 'C-u M-x erl-ping'.

Any suggestions for a key-binding? 'C-c C-d @' or 'C-c C-d !' perhaps?


Regards,


Matthias.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/