aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/breakpoint_client.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-04-28 15:57:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-04-28 15:57:29 +0000
commit70ac560e42644938392381ecd52efd7fb0260323 (patch)
treedbc0bc73d480bf3af99aef2f4be16afa183f4850 /railties/lib/breakpoint_client.rb
parent1d5c34c2c27370356e8cd1ef478111802b6a5af4 (diff)
downloadrails-70ac560e42644938392381ecd52efd7fb0260323.tar.gz
rails-70ac560e42644938392381ecd52efd7fb0260323.tar.bz2
rails-70ac560e42644938392381ecd52efd7fb0260323.zip
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
Diffstat (limited to 'railties/lib/breakpoint_client.rb')
-rw-r--r--railties/lib/breakpoint_client.rb196
1 files changed, 0 insertions, 196 deletions
diff --git a/railties/lib/breakpoint_client.rb b/railties/lib/breakpoint_client.rb
deleted file mode 100644
index 9273321599..0000000000
--- a/railties/lib/breakpoint_client.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-require 'breakpoint'
-require 'optparse'
-require 'timeout'
-
-Options = {
- :ClientURI => nil,
- :ServerURI => "druby://localhost:42531",
- :RetryDelay => 2,
- :Permanent => true,
- :Verbose => false
-}
-
-ARGV.options do |opts|
- script_name = File.basename($0)
- opts.banner = [
- "Usage: ruby #{script_name} [Options] [server uri]",
- "",
- "This tool lets you connect to a breakpoint service ",
- "which was started via Breakpoint.activate_drb.",
- "",
- "The server uri defaults to druby://localhost:42531"
- ].join("\n")
-
- opts.separator ""
-
- opts.on("-c", "--client-uri=uri",
- "Run the client on the specified uri.",
- "This can be used to specify the port",
- "that the client uses to allow for back",
- "connections from the server.",
- "Default: Find a good URI automatically.",
- "Example: -c druby://localhost:12345"
- ) { |v| Options[:ClientURI] = v }
-
- opts.on("-s", "--server-uri=uri",
- "Connect to the server specified at the",
- "specified uri.",
- "Default: druby://localhost:42531"
- ) { |v| Options[:ServerURI] = v }
-
- opts.on("-R", "--retry-delay=delay", Integer,
- "Automatically try to reconnect to the",
- "server after delay seconds when the",
- "connection failed or timed out.",
- "A value of 0 disables automatical",
- "reconnecting completely.",
- "Default: 10"
- ) { |v| Options[:RetryDelay] = v }
-
- opts.on("-P", "--[no-]permanent",
- "Run the breakpoint client in permanent mode.",
- "This means that the client will keep continue",
- "running even after the server has closed the",
- "connection. Useful for example in Rails."
- ) { |v| Options[:Permanent] = v }
-
- opts.on("-V", "--[no-]verbose",
- "Run the breakpoint client in verbose mode.",
- "Will produce more messages, for example between",
- "individual breakpoints. This might help in seeing",
- "that the breakpoint client is still alive, but adds",
- "quite a bit of clutter."
- ) { |v| Options[:Verbose] = v }
-
- opts.separator ""
-
- opts.on("-h", "--help",
- "Show this help message."
- ) { puts opts; exit }
- opts.on("-v", "--version",
- "Display the version information."
- ) do
- id = %q$Id: breakpoint_client.rb 91 2005-02-04 22:34:08Z flgr $
- puts id.sub("Id: ", "")
- puts "(Breakpoint::Version = #{Breakpoint::Version})"
- exit
- end
-
- opts.parse!
-end
-
-Options[:ServerURI] = ARGV[0] if ARGV[0]
-
-module Handlers #:nodoc:
- extend self
-
- def breakpoint_handler(workspace, message)
- puts message
- IRB.start(nil, nil, workspace)
-
- puts ""
- if Options[:Verbose] then
- puts "Resumed execution. Waiting for next breakpoint...", ""
- end
- end
-
- def eval_handler(code)
- result = eval(code, TOPLEVEL_BINDING)
- if result then
- DRbObject.new(result)
- else
- result
- end
- end
-
- def collision_handler()
- msg = [
- " *** Breakpoint service collision ***",
- " Another Breakpoint service tried to use the",
- " port already occupied by this one. It will",
- " keep waiting until this Breakpoint service",
- " is shut down.",
- " ",
- " If you are using the Breakpoint library for",
- " debugging a Rails or other CGI application",
- " this likely means that this Breakpoint",
- " session belongs to an earlier, outdated",
- " request and should be shut down via 'exit'."
- ].join("\n")
-
- if RUBY_PLATFORM["win"] then
- # This sucks. Sorry, I'm not doing this because
- # I like funky message boxes -- I need to do this
- # because on Windows I have no way of displaying
- # my notification via puts() when gets() is still
- # being performed on STDIN. I have not found a
- # better solution.
- begin
- require 'tk'
- root = TkRoot.new { withdraw }
- Tk.messageBox('message' => msg, 'type' => 'ok')
- root.destroy
- rescue Exception
- puts "", msg, ""
- end
- else
- puts "", msg, ""
- end
- end
-end
-
-# Used for checking whether we are currently in the reconnecting loop.
-reconnecting = false
-
-loop do
- DRb.start_service(Options[:ClientURI])
-
- begin
- service = DRbObject.new(nil, Options[:ServerURI])
-
- begin
- ehandler = Handlers.method(:eval_handler)
- chandler = Handlers.method(:collision_handler)
- handler = Handlers.method(:breakpoint_handler)
- service.eval_handler = ehandler
- service.collision_handler = chandler
- service.handler = handler
-
- reconnecting = false
- if Options[:Verbose] then
- puts "Connection established. Waiting for breakpoint...", ""
- end
-
- loop do
- begin
- service.ping
- rescue DRb::DRbConnError => error
- puts "Server exited. Closing connection...", ""
- exit! unless Options[:Permanent]
- break
- end
-
- sleep(0.5)
- end
- ensure
- service.eval_handler = nil
- service.collision_handler = nil
- service.handler = nil
- end
- rescue Exception => error
- if Options[:RetryDelay] > 0 then
- if not reconnecting then
- reconnecting = true
- puts "No connection to breakpoint service at #{Options[:ServerURI]} " +
- "(#{error.class})"
- puts error.backtrace if $DEBUG
- puts "Tries to connect will be made every #{Options[:RetryDelay]} seconds..."
- end
-
- sleep Options[:RetryDelay]
- retry
- else
- raise
- end
- end
-end