Skip to content

Commit

Permalink
Move debugger into middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Nov 25, 2008
1 parent 07abc5e commit c80fe10
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
13 changes: 1 addition & 12 deletions railties/lib/commands/server.rb
Expand Up @@ -83,22 +83,11 @@
app = Rack::Builder.new {
use Rails::Rack::Logger
use Rails::Rack::Static
use Rails::Rack::Debugger if options[:debugger]
run ActionController::Dispatcher.new
}.to_app
end

if options[:debugger]
begin
require_library_or_gem 'ruby-debug'
Debugger.start
Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
puts "=> Debugger enabled"
rescue Exception
puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
exit
end
end

puts "=> Call with -d to detach"

trap(:INT) { exit }
Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/rack.rb
@@ -1,5 +1,6 @@
module Rails
module Rack
autoload :Debugger, "rails/rack/debugger"
autoload :Logger, "rails/rack/logger"
autoload :Static, "rails/rack/static"
end
Expand Down
21 changes: 21 additions & 0 deletions railties/lib/rails/rack/debugger.rb
@@ -0,0 +1,21 @@
module Rails
module Rack
class Debugger
def initialize(app)
@app = app

require_library_or_gem 'ruby-debug'
::Debugger.start
::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
puts "=> Debugger enabled"
rescue Exception
puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
exit
end

def call(env)
@app.call(env)
end
end
end
end

1 comment on commit c80fe10

@elecnix
Copy link

@elecnix elecnix commented on c80fe10 Mar 8, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't liike this "rescue Exception" which hides any other problem with loading ruby-debug. For example, ruby-debug-0.10.3/cli/ruby-debug/interface.rb fails because of "uninitialized constant Debugger::LocalInterface::Readline" and the message printed is "You need to install ruby-debug" although it is installed.

Please sign in to comment.