Re: [jruby-user] Debugging JRuby running within a Java process
Christian MICHON <[email protected]> Mon, 12 Jan 2015 08:17:12 +0100
| Newsgroups | gmane.comp.lang.jruby.user |
|---|---|
| Message-ID | <CACx2yF89fDO8U-ybyqxEXNLwsTXZQyfabNyavrxhJ=TEF=cAOg@mail.gmail.com> |
I would suggest using pry-remote (https://rubygems.org/gems/pry-remote) instead. This would require it to be part of your gemfile, but this would work perfectly: this is how we debug server applications once deployed as war files (but only if they go into specific exceptions). Good luck. On Sat, Jan 10, 2015 at 9:03 PM, Chason Choate < [email protected]> wrote: > Hello world! > > So i'm currently trying to figure out how to debug a JRuby on Rails app > that is running within a Java application. I'll attempt to describe the > stack. > > We have a Java app that uses the JRuby ScriptingContainer > <http://jruby.org/apidocs/org/jruby/embed/ScriptingContainer.html> to > launch the rails app. > > ScriptingContainer ruby = new > ScriptingContainer(LocalContextScope.THREADSAFE, > LocalVariableBehavior.TRANSIENT); > ... > File rackup = new File(railsPath, "config.ru"); > rackupContent = FileUtils.fetchFile(rackup, StandardCharsets.UTF_8.name > ()); > ruby.put("rackup_script", rackupContent); > ruby.put("rackup_file", rackup.getAbsolutePath()); > IRubyObject railsApp = ruby.parse("require 'rack'; > Rack::Builder.new_from_string(rackup_script, file=rackup_file)").run(); > > Then we pass the rails application to the rack servlet > <https://github.com/square/rack-servlet> which allows the network > requests to flow into the rails app. > > return new RackServlet(new JRubyRackApplication(railsApp)); > > At this point the app is running fine i'm just not sure how to start > debugging. Here are some of the things i'm confused about. > > 1. I've read this article > <https://github.com/jruby/jruby/wiki/UsingTheJRubyDebugger> but I am not > sure how to start the rails app with: jruby --debug -S rdebug > 2. Would it be possible to use standard java debugging with this setup? > 3. Has anyone went down this path before and came out with a better > solution, as far as launching the rails app? > * The Java portion in mandatory but the way the rails app is launched > could be changed. > > > -- > Thanks for your time, > Chason Choate > -- Christian