From 70ac560e42644938392381ecd52efd7fb0260323 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 28 Apr 2007 15:57:29 +0000 Subject: Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6611 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/commands/servers/base.rb | 12 ++++++++++++ railties/lib/commands/servers/mongrel.rb | 6 +++++- railties/lib/commands/servers/webrick.rb | 20 +++++++++++++------- 3 files changed, 30 insertions(+), 8 deletions(-) (limited to 'railties/lib/commands/servers') diff --git a/railties/lib/commands/servers/base.rb b/railties/lib/commands/servers/base.rb index 25b2935524..ed32c3eea5 100644 --- a/railties/lib/commands/servers/base.rb +++ b/railties/lib/commands/servers/base.rb @@ -17,3 +17,15 @@ def tail(log_file) end tail_thread end + +def start_debugger + begin + require_library_or_gem 'ruby-debug' + Debugger.start + # Debugger.settings[:autoirb] = true + 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 \ No newline at end of file diff --git a/railties/lib/commands/servers/mongrel.rb b/railties/lib/commands/servers/mongrel.rb index 995274f9a0..5eb14bce1e 100644 --- a/railties/lib/commands/servers/mongrel.rb +++ b/railties/lib/commands/servers/mongrel.rb @@ -12,13 +12,15 @@ OPTIONS = { :port => 3000, :ip => "0.0.0.0", :environment => (ENV['RAILS_ENV'] || "development").dup, - :detach => false + :detach => false, + :debugger => false } ARGV.clone.options do |opts| opts.on("-p", "--port=port", Integer, "Runs Rails on the specified port.", "Default: 3000") { |v| OPTIONS[:port] = v } opts.on("-b", "--binding=ip", String, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v } opts.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS[:detach] = true } + opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } opts.on("-e", "--environment=name", String, "Specifies the environment to run this server under (test/development/production).", "Default: development") { |v| OPTIONS[:environment] = v } @@ -46,6 +48,8 @@ else ENV["RAILS_ENV"] = OPTIONS[:environment] RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) + start_debugger if OPTIONS[:debugger] + require 'initializer' Rails::Initializer.run(:initialize_logger) diff --git a/railties/lib/commands/servers/webrick.rb b/railties/lib/commands/servers/webrick.rb index 3fddcc5459..0f06560457 100644 --- a/railties/lib/commands/servers/webrick.rb +++ b/railties/lib/commands/servers/webrick.rb @@ -2,13 +2,15 @@ require 'webrick' require 'optparse' OPTIONS = { - :port => 3000, - :ip => "0.0.0.0", - :environment => (ENV['RAILS_ENV'] || "development").dup, - :server_root => File.expand_path(RAILS_ROOT + "/public/"), - :server_type => WEBrick::SimpleServer, - :charset => "UTF-8", - :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes + :port => 3000, + :ip => "0.0.0.0", + :environment => (ENV['RAILS_ENV'] || "development").dup, + :server_root => File.expand_path(RAILS_ROOT + "/public/"), + :server_type => WEBrick::SimpleServer, + :charset => "UTF-8", + :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes, + :debugger => false + } ARGV.options do |opts| @@ -34,6 +36,8 @@ ARGV.options do |opts| "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)." ) { OPTIONS[:server_type] = WEBrick::Daemon } + opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } + opts.on("-c", "--charset=charset", String, "Set default charset for output.", "Default: UTF-8") { |v| OPTIONS[:charset] = v } @@ -46,6 +50,8 @@ ARGV.options do |opts| opts.parse! end +start_debugger if OPTIONS[:debugger] + ENV["RAILS_ENV"] = OPTIONS[:environment] RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) -- cgit v1.2.3