diff options
author | bricolage <bricolage@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-09-26 21:25:44 +0000 |
---|---|---|
committer | bricolage <bricolage@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-09-26 21:25:44 +0000 |
commit | 89c3e98c96589fda499bfa389aff6b9ec0d9da8e (patch) | |
tree | 9673be8882d3c23ad6862e5ba77cb2fa341bdcbe /lib | |
parent | bd5e6347889e1ac07256228935f6d4a73c872f64 (diff) | |
download | unicorn-89c3e98c96589fda499bfa389aff6b9ec0d9da8e.tar.gz |
* Improve messaging for config file generation * Remove unnecessary local var for config_file merging in mongrel_rails * Add Iowa to list of supported frameworks in gem spec git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@353 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mongrel.rb | 9 | ||||
-rw-r--r-- | lib/mongrel/configurator.rb | 2 | ||||
-rw-r--r-- | lib/mongrel/handlers.rb | 3 | ||||
-rw-r--r-- | lib/mongrel/rails.rb | 33 |
4 files changed, 22 insertions, 25 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb index 07729fc..57cfb6a 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -47,6 +47,7 @@ module Mongrel # Used to stop the HttpServer via Thread.raise. class StopServer < Exception; end + # Thrown at a thread when it is timed out. class TimeoutError < Exception; end @@ -95,7 +96,6 @@ module Mongrel } - # Frequently used constants when constructing requests or responses. Many times # the constant just refers to a string with the same contents. Using these constants # gave about a 3% to 10% performance improvement over using the strings directly. @@ -160,11 +160,13 @@ module Mongrel REDIRECT = "HTTP/1.1 302 Found\r\nLocation: %s\r\nConnection: close\r\n\r\n".freeze end + # Basically a Hash with one extra parameter for the HTTP body, mostly used internally. class HttpParams < Hash attr_accessor :http_body end + # When a handler is found for a registered URI then this class is constructed # and passed to your HttpHandler::process method. You should assume that # *one* handler processes all requests. Included in the HttpRequest is a @@ -324,6 +326,7 @@ module Mongrel end end + # Writes and controls your response to the client using the HTTP/1.1 specification. # You use it by simply doing: # @@ -484,6 +487,7 @@ module Mongrel end + # This is the main driver of Mongrel, while the Mongrel::HttpParser and Mongrel::URIClassifier # make up the majority of how the server functions. It's a very simple class that just # has a thread accepting connections and a simple HttpServer.process_client function @@ -537,7 +541,6 @@ module Mongrel @death_time = 60 end - # Does the majority of the IO processing. It has been written in Ruby using # about 7 different IO processing strategies and no matter how it's done # the performance just does not improve. It is currently carefully constructed @@ -704,14 +707,12 @@ module Mongrel STDERR.puts $!.backtrace.join("\n") if $mongrel_debug_client end end - graceful_shutdown end return @acceptor end - # Simply registers a handler with the internal URIClassifier. When the URI is # found in the prefix of a request then your handler's HttpHandler::process method # is called. See Mongrel::URIClassifier#register for more information. diff --git a/lib/mongrel/configurator.rb b/lib/mongrel/configurator.rb index 5f71f3f..223ad84 100644 --- a/lib/mongrel/configurator.rb +++ b/lib/mongrel/configurator.rb @@ -252,7 +252,7 @@ module Mongrel GemPlugin::Manager.instance.create(name, ops) end - # Let's you do redirects easily as described in Mongrel::RedirectHandler. + # Lets you do redirects easily as described in Mongrel::RedirectHandler. # You use it inside the configurator like this: # # redirect("/test", "/to/there") # simple diff --git a/lib/mongrel/handlers.rb b/lib/mongrel/handlers.rb index b0a399b..a5f225e 100644 --- a/lib/mongrel/handlers.rb +++ b/lib/mongrel/handlers.rb @@ -101,8 +101,7 @@ module Mongrel # can change it anything you want using the DirHandler.default_content_type # attribute. class DirHandler < HttpHandler - attr_reader :default_content_type - attr_writer :default_content_type + attr_accessor :default_content_type attr_reader :path MIME_TYPES = { diff --git a/lib/mongrel/rails.rb b/lib/mongrel/rails.rb index e351cec..1e6b990 100644 --- a/lib/mongrel/rails.rb +++ b/lib/mongrel/rails.rb @@ -32,9 +32,8 @@ module Mongrel # * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go. # # This means that if you are using page caching it will actually work with Mongrel - # and you should see a decent speed boost (but not as fast as if you use lighttpd). - # - # An additional feature you can use is + # and you should see a decent speed boost (but not as fast as if you use a static + # server like Apache or Litespeed). class RailsHandler < Mongrel::HttpHandler attr_reader :files attr_reader :guard @@ -45,13 +44,12 @@ module Mongrel @guard = Sync.new @tick = Time.now - # register the requested mime types + # Register the requested MIME types mime_map.each {|k,v| Mongrel::DirHandler::add_mime_type(k,v) } end # Attempts to resolve the request as follows: # - # # * If the requested exact PATH_INFO exists as a file then serve it. # * If it exists at PATH_INFO+".html" exists then serve that. # * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go. @@ -68,14 +66,14 @@ module Mongrel # File exists as-is so serve it up @files.process(request,response) elsif get_or_head and @files.can_serve(page_cached) - # possible cached page, serve it up + # Possible cached page, serve it up request.params[Mongrel::Const::PATH_INFO] = page_cached @files.process(request,response) else begin cgi = Mongrel::CGIWrapper.new(request, response) cgi.handler = self - # we don't want the output to be really final until we're out of the lock + # We don't want the output to be really final until we're out of the lock cgi.default_really_final = false log_threads_waiting_for(request.params["PATH_INFO"] || @active_request_path) if $mongrel_debug_client @@ -99,7 +97,7 @@ module Mongrel def log_threads_waiting_for(event) if Time.now - @tick > 10 - STDERR.puts "#{Time.now}: #{@guard.sync_waiting.length} threads sync_waiting for #{event}, #{self.listener.workers.list.length} still active in mongrel." + STDERR.puts "#{Time.now}: #{@guard.sync_waiting.length} threads sync_waiting for #{event}, #{self.listener.workers.list.length} still active in Mongrel." @tick = Time.now end end @@ -123,7 +121,7 @@ module Mongrel class RailsConfigurator < Mongrel::Configurator # Creates a single rails handler and returns it so you - # can add it to a uri. You can actually attach it to + # can add it to a URI. You can actually attach it to # as many URIs as you want, but this returns the # same RailsHandler for each call. # @@ -141,10 +139,10 @@ module Mongrel # one installed per Ruby interpreter (talk to them # about thread safety). Because of this the first # time you call this function it does all the config - # needed to get your rails working. After that + # needed to get your Rails working. After that # it returns the one handler you've configured. - # This lets you attach Rails to any URI (and multiple) - # you want, but still protects you from threads destroying + # This lets you attach Rails to any URI(s) you want, + # but it still protects you from threads destroying # your handler. def rails(options={}) @@ -169,18 +167,17 @@ module Mongrel @rails_handler = RailsHandler.new(ops[:docroot], ops[:mime]) end - - # Reloads rails. This isn't too reliable really, but - # should work for most minimal reload purposes. Only reliable - # way it so stop then start the process. + # Reloads Rails. This isn't too reliable really, but it + # should work for most minimal reload purposes. The only reliable + # way to reload properly is to stop and then start the process. def reload! if not @rails_handler raise "Rails was not configured. Read the docs for RailsConfigurator." end - log "Reloading rails..." + log "Reloading Rails..." @rails_handler.reload! - log "Done reloading rails." + log "Done reloading Rails." end |