about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--bin/mongrel_rails8
-rw-r--r--lib/mongrel.rb9
-rw-r--r--lib/mongrel/command.rb2
-rw-r--r--lib/mongrel/debug.rb13
-rw-r--r--test/test_configurator.rb4
5 files changed, 31 insertions, 5 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index 20784bb..679c1e2 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -22,7 +22,8 @@ class Start < GemPlugin::Plugin "/commands"
       ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
       ['-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]
+      ['-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]
     ]
   end
   
@@ -83,6 +84,11 @@ class Start < GemPlugin::Plugin "/commands"
         log "Loading any Rails specific GemPlugins"
         load_plugins
 
+        if settings[:config_script]
+          log "Loading #{settings[:config_script]} external config script"
+          run_config("config/mongrel.rb")
+        end
+
         setup_rails_signals
       end
     end
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index e3f7653..25b9062 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -725,7 +725,6 @@ module Mongrel
     # is organized.
     def load_mime_map(file, mime={})
       # configure any requested mime map
-      log "Loading additional MIME types from #{file}"
       mime = load_yaml(file, mime)
       
       # check all the mime types to make sure they are the right format
@@ -786,11 +785,19 @@ module Mongrel
       MongrelDbg.begin_trace :rails
       MongrelDbg.begin_trace :files
       
+      uri location, :handler => plugin("/handlers/requestlog::access")
       uri location, :handler => plugin("/handlers/requestlog::files")
       uri location, :handler => plugin("/handlers/requestlog::objects")
       uri location, :handler => plugin("/handlers/requestlog::params")
     end
 
+    # Used to allow you to let users specify their own configurations
+    # inside your Configurator setup.  You pass it a script name and
+    # reads it in and does an eval on the contents passing in the right
+    # binding so they can put their own Configurator statements.
+    def run_config(script)
+      open(script) {|f| eval(f.read, proc {self}) }
+    end
 
     # Sets up the standard signal handlers that are used on most Ruby
     # It only configures if the platform is not win32 and doesn't do
diff --git a/lib/mongrel/command.rb b/lib/mongrel/command.rb
index 0341e15..a500ce0 100644
--- a/lib/mongrel/command.rb
+++ b/lib/mongrel/command.rb
@@ -52,7 +52,7 @@ module Mongrel
         @opt.on_tail("--version", "Show version") do
           @done_validating = true
           if VERSION
-            puts "Version #{VERSION}"
+            puts "Version #{MONGREL_VERSION}"
           end
         end
         
diff --git a/lib/mongrel/debug.rb b/lib/mongrel/debug.rb
index 6178872..e3c6504 100644
--- a/lib/mongrel/debug.rb
+++ b/lib/mongrel/debug.rb
@@ -219,6 +219,19 @@ end
 
 
 module RequestLog
+
+  # Just logs whatever requests it gets to STDERR (which ends up in the mongrel
+  # log when daemonized).
+  class Access < GemPlugin::Plugin "/handlers"
+    include Mongrel::HttpHandlerPlugin
+    
+    def process(request,response)
+      p = request.params
+      STDERR.puts "#{p['REMOTE_ADDR']} - [#{HttpServer.httpdate(Time.now)}] \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\""
+    end
+  end
+  
+
   class Files < GemPlugin::Plugin "/handlers"
     include Mongrel::HttpHandlerPlugin
     
diff --git a/test/test_configurator.rb b/test/test_configurator.rb
index 2aacda2..657e135 100644
--- a/test/test_configurator.rb
+++ b/test/test_configurator.rb
@@ -29,12 +29,12 @@ class ConfiguratorTest < Test::Unit::TestCase
         # 2 in front should run, but the sentinel shouldn't since dirhandler processes the request
         uri "/", :handler => plugin("/handlers/testplugin")
         uri "/", :handler => plugin("/handlers/testplugin")
-        uri "/", :handler => Mongrel::DirHandler.new(".", load_mime_map("examples/mime.yaml"))
+        uri "/", :handler => Mongrel::DirHandler.new(".")
         uri "/", :handler => plugin("/handlers/testplugin")
 
         uri "/test", :handler => plugin("/handlers/testplugin")
         uri "/test", :handler => plugin("/handlers/testplugin")
-        uri "/test", :handler => Mongrel::DirHandler.new(".", load_mime_map("examples/mime.yaml"))
+        uri "/test", :handler => Mongrel::DirHandler.new(".")
         uri "/test", :handler => plugin("/handlers/testplugin")
         run
       end