aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-19 06:25:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-19 06:25:47 +0000
commit03acf48817d38e8ec4078d50f6ab48a2dfc035b3 (patch)
treeb23271a227c720cd3ae7c6289ef387ad8b27b4b5 /railties
parent8fb9d7cb4a2ae2bab862aa3e05753ddbdee37632 (diff)
downloadrails-03acf48817d38e8ec4078d50f6ab48a2dfc035b3.tar.gz
rails-03acf48817d38e8ec4078d50f6ab48a2dfc035b3.tar.bz2
rails-03acf48817d38e8ec4078d50f6ab48a2dfc035b3.zip
Added SIGTRAP signal handler to RailsFCGIHandler that'll force the process into a breakpoint after the next request. This breakpoint can then be caught with script/breakpointer and give you access to the Ruby image inside that process. Useful for debugging memory leaks among other things [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3618 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/fcgi_handler.rb26
2 files changed, 24 insertions, 4 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 9c88925c8a..fe3356dbcb 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added SIGTRAP signal handler to RailsFCGIHandler that'll force the process into a breakpoint after the next request. This breakpoint can then be caught with script/breakpointer and give you access to the Ruby image inside that process. Useful for debugging memory leaks among other things [DHH]
+
* Update script.aculo.us to V1.5.2 [Thomas Fuchs]
* Changed default lighttpd.conf to use CWD from lighttpd 1.4.10 that allows the same configuration to be used for both detach and not. Also ensured that auto-repeaping of FCGIs only happens when lighttpd is not detached. [DHH]
diff --git a/railties/lib/fcgi_handler.rb b/railties/lib/fcgi_handler.rb
index 0170d6904e..10f846fa13 100644
--- a/railties/lib/fcgi_handler.rb
+++ b/railties/lib/fcgi_handler.rb
@@ -5,10 +5,11 @@ require 'rbconfig'
class RailsFCGIHandler
SIGNALS = {
- 'HUP' => :reload,
- 'TERM' => :exit_now,
- 'USR1' => :exit,
- 'USR2' => :restart
+ 'HUP' => :reload,
+ 'TERM' => :exit_now,
+ 'USR1' => :exit,
+ 'USR2' => :restart,
+ 'SIGTRAP' => :breakpoint
}
attr_reader :when_ready
@@ -61,6 +62,9 @@ class RailsFCGIHandler
when :exit
close_connection(cgi)
break
+ when :breakpoint
+ close_connection(cgi)
+ breakpoint!
end
gc_countdown
@@ -137,6 +141,11 @@ class RailsFCGIHandler
@when_ready = :restart
end
+ def breakpoint_handler(signal)
+ dispatcher_log :info, "asked to breakpoint ASAP"
+ @when_ready = :breakpoint
+ end
+
def process_request(cgi)
Dispatcher.dispatch(cgi)
rescue Object => e
@@ -170,6 +179,15 @@ class RailsFCGIHandler
Dispatcher.reset_application!
ActionController::Routing::Routes.reload
end
+
+ def breakpoint!
+ require 'breakpoint'
+ port = defined?(BREAKPOINT_SERVER_PORT) ? BREAKPOINT_SERVER_PORT : 42531
+ Breakpoint.activate_drb("druby://localhost:#{port}", nil, !defined?(FastCGI))
+ dispatcher_log :info, "breakpointing"
+ breakpoint
+ @when_ready = nil
+ end
def run_gc!
@gc_request_countdown = gc_request_period