Forum: Ruby Connecting to a running ruby process

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7e85c8b066ffb802cba005e90c6c616e?d=identicon&s=25 Piyush Ranjan (Guest)
on 2009-01-19 10:23
(Received via mailing list)
Hi!
Is there any way you can connect to a running ruby process (for instance
a
mongrel) and 'talk' to it like we can do in lisp using slime ?
For instance in you may connect to a running lisp image (like a
hunchentoot
web server) and inspect variables as they get created and destroyed. I
find
such a 'back-door'(if we may call it) very powerful. I remember there
was
something called a breakpoint or debug built into rails. However that is
not
what I am actually looking at.

Piyush
F778607e066c8372ab94b0920ed7b2b8?d=identicon&s=25 Jakub Pavlík jn. (Guest)
on 2009-01-19 11:05
(Received via mailing list)
> Hi!
> Is there any way you can connect to a running ruby process (for instance a
> mongrel) and 'talk' to it like we can do in lisp using slime ?
> For instance in you may connect to a running lisp image (like a hunchentoot
> web server) and inspect variables as they get created and destroyed. I find
> such a 'back-door'(if we may call it) very powerful. I remember there was
> something called a breakpoint or debug built into rails. However that is not
> what I am actually looking at.
>
> Piyush

Look at LiveConsole:
http://rubyforge.org/projects/live-console/
(Maybe it isn't directly what you need, but it might help)

--
"Configure complete, now type 'make' and PRAY."

                (configure script of zsnes - www.zsnes.com)
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-01-19 11:33
Piyush Ranjan wrote:
> Hi!
> Is there any way you can connect to a running ruby process (for instance
> a
> mongrel) and 'talk' to it like we can do in lisp using slime ?

Try the ruby-debug gem (which is what rails uses). Unfortunately, the
supplied documentation is pretty poor, but there is a pretty good doc at
http://bashdb.sourceforge.net/ruby-debug.html

Separate process debugging can be done via rdebug command line flags, or
by calling Debugger methods explicitly:

$ cat p1.rb
require 'rubygems'
require 'ruby-debug'

Debugger.wait_connection = true
Debugger.start_remote
Debugger.post_mortem

Debugger.breakpoint
a = 1 - 1
b = 2 / a
c = a + b
puts c

$ ruby p1.rb

In another window: rdebug -c to single step, inspect variables etc. in
the first process.
This topic is locked and can not be replied to.