about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--Rakefile2
-rw-r--r--bin/mongrel_rails41
-rw-r--r--lib/mongrel.rb9
-rw-r--r--lib/mongrel/configurator.rb2
-rw-r--r--lib/mongrel/handlers.rb3
-rw-r--r--lib/mongrel/rails.rb33
6 files changed, 41 insertions, 49 deletions
diff --git a/Rakefile b/Rakefile
index 5e92988..8db0740 100644
--- a/Rakefile
+++ b/Rakefile
@@ -56,7 +56,7 @@ name="mongrel"
 version="0.3.13.5"
 
 setup_gem(name, version) do |spec|
-  spec.summary = "A small fast HTTP library and server that runs Rails, Camping, and Nitro apps."
+  spec.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps."
   spec.description = spec.summary
   spec.test_files = Dir.glob('test/test_*.rb')
   spec.author="Zed A. Shaw"
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index d96dc5d..eb64dd6 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -17,7 +17,7 @@ module Mongrel
     def configure
       options [
         ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
-        ["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false],
+        ["-d", "--daemonize", "Run daemonized in the background", :@daemon, false],
         ['-p', '--port PORT', "Which port to bind to", :@port, 3000],
         ['-a', '--address ADDR', "Address to bind to", :@address, "0.0.0.0"],
         ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/mongrel.log"],
@@ -29,11 +29,11 @@ module Mongrel
         ['-r', '--root PATH', "Set the document root (default 'public')", :@docroot, "public"],
         ['-B', '--debug', "Enable debugging mode", :@debug, false],
         ['-C', '--config PATH', "Use a config file", :@config_file, nil],
-        ['-S', '--script PATH', "Load the given file as an extra config script.", :@config_script, nil],
-        ['-G', '--generate CONFIG', "Generate a config file for -C", :@generate, nil],
-        ['', '--user USER', "User to run as", :@user, nil],
-        ['', '--group GROUP', "Group to run as", :@group, nil],
-        ['', '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
+        ['-S', '--script PATH', "Load the given file as an extra config script", :@config_script, nil],
+        ['-G', '--generate PATH', "Generate a config file for use with -C", :@generate, nil],
+        [nil, '--user USER', "User to run as", :@user, nil],
+        [nil, '--group GROUP', "Group to run as", :@group, nil],
+        [nil, '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
       ]
     end
 
@@ -41,7 +41,7 @@ module Mongrel
       @cwd = File.expand_path(@cwd)
       valid_dir? @cwd, "Invalid path to change to during daemon mode: #@cwd"
 
-      # change there to start, then we'll have to come back after daemonize
+      # Change there to start, then we'll have to come back after daemonize
       Dir.chdir(@cwd)
 
       valid?(@prefix[0].chr == "/" && @prefix[-1].chr != "/", "Prefix must begin with / and not end in /") if @prefix
@@ -57,10 +57,8 @@ module Mongrel
       return @valid
     end
 
-
     def run
-
-      # command line setting override config file settings
+      # Config file settings will override command line settings
       settings = { :host => @address,  :port => @port, :cwd => @cwd,
         :log_file => @log_file, :pid_file => @pid_file, :environment => @environment,
         :docroot => @docroot, :mime_map => @mime_map, :daemon => @daemon,
@@ -70,22 +68,21 @@ module Mongrel
       }
 
       if @generate
-        STDERR.puts "** Writing config to #@generate"
+        STDERR.puts "** Writing config to \"#@generate\"."
         open(@generate, "w") {|f| f.write(settings.to_yaml) }
-        STDERR.puts "## Exiting. Re-run without -G and WITH -C using your new config file."
+        STDERR.puts "** Finished.  Run \"mongrel_rails -C #@generate\" to use the config file."
         exit 0
       end
 
       if @config_file
-        conf = YAML.load_file(@config_file)
-        settings = settings.merge! conf
+        settings.merge! YAML.load_file(@config_file)
         STDERR.puts "** Loading settings from #{@config_file} (they override command line)." unless settings[:daemon]
       end
 
       config = Mongrel::Rails::RailsConfigurator.new(settings) do
         if defaults[:daemon]
           if File.exist? defaults[:pid_file]
-            log "!!! PID file #{defaults[:pid_file]} already exists.  Mongrel could be running already. Check your #{defaults[:log_file]} for errors."
+            log "!!! PID file #{defaults[:pid_file]} already exists.  Mongrel could be running already.  Check your #{defaults[:log_file]} for errors."
           end
 
           daemonize
@@ -103,7 +100,7 @@ module Mongrel
           end
 
           if defaults[:debug]
-            log "Installing debugging prefixed filters.  Look in log/mongrel_debug for the files."
+            log "Installing debugging prefixed filters. Look in log/mongrel_debug for the files."
             debug "/"
           end
 
@@ -173,9 +170,9 @@ module Mongrel
 
     def configure
       options [
-        ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, "."],
+        ['-c', '--chdir PATH', "Change to dir before starting (will be expanded).", :@cwd, "."],
         ['-f', '--force', "Force the shutdown.", :@force, false],
-        ['-P', '--pid FILE', "Where the PID file is located", :@pid_file, "log/mongrel.pid"]
+        ['-P', '--pid FILE', "Where the PID file is located.", :@pid_file, "log/mongrel.pid"]
       ]
     end
 
@@ -185,11 +182,10 @@ module Mongrel
 
       Dir.chdir @cwd
 
-      valid_exists? @pid_file, "PID file #@pid_file does not exist. Not running?"
+      valid_exists? @pid_file, "PID file #@pid_file does not exist.  Not running?"
       return @valid
     end
 
-
     def run
       if @force
         Mongrel::send_signal("KILL", @pid_file)
@@ -200,7 +196,6 @@ module Mongrel
   end
 
 
-
   class Restart < GemPlugin::Plugin "/commands"
     include Mongrel::Command::Base
 
@@ -218,11 +213,10 @@ module Mongrel
 
       Dir.chdir @cwd
 
-      valid_exists? @pid_file, "PID file #@pid_file does not exist. Not running?"
+      valid_exists? @pid_file, "PID file #@pid_file does not exist.  Not running?"
       return @valid
     end
 
-
     def run
       if @soft
         Mongrel::send_signal("HUP", @pid_file)
@@ -236,6 +230,7 @@ end
 
 GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
 
+
 if not Mongrel::Command::Registry.instance.run ARGV
   exit 1
 end
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