<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/rack/adapter/loader.rb</filename>
    </added>
    <added>
      <filename>spec/rack/loader_spec.rb</filename>
    </added>
    <added>
      <filename>spec/rack/rails_adapter_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,7 @@
+== 0.8.0 ??? release
+ * Guess which adapter to use from directory (chdir option)
+   or use specified one in 'adapter' option, re #47.
+
 == 0.7.1 Fancy Pants release
  * Clean stale PID files when starting as daemon, fixes #53 [Chu Yeow]
  * Require EventMachine 0.11.0 for UNIX domain sockets. Until it's released, install from:</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -37,6 +37,7 @@ module Thin
 end
 
 require 'rack'
+require 'rack/adapter/loader'
 
 module Rack
   module Handler</diff>
      <filename>lib/thin.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,22 @@
 require 'yaml'
 
 module Thin
-  # Build and control one Thin server.
-  # Hey Controller pattern is not only for web apps yo!
-  module Controllers
-    # Raised when a mandatory option is missing to run a command.
-    class OptionRequired &lt; RuntimeError
-      def initialize(option)
-        super(&quot;#{option} option required&quot;)
-      end
+  # Error raised that will abort the process and print not backtrace.
+  class RunnerError &lt; RuntimeError; end
+  
+  # Raised when a mandatory option is missing to run a command.
+  class OptionRequired &lt; RunnerError
+    def initialize(option)
+      super(&quot;#{option} option required&quot;)
     end
+  end
+  
+  # Raised when an option is not valid.
+  class InvalidOption &lt; RunnerError; end
   
+  # Build and control one Thin server.
+  # Hey Controller pattern is not only for web apps yo!
+  module Controllers  
     # Controls a Thin server.
     # Allow to start, stop, restart and configure a single thin server.
     class Controller
@@ -55,13 +61,11 @@ module Thin
         server.change_privilege @options[:user], @options[:group] if @options[:user] &amp;&amp; @options[:group]
 
         # If a Rack config file is specified we eval it inside a Rack::Builder block to create
-        # a Rack adapter from it. DHH was hacker of the year a couple years ago so we default
-        # to Rails adapter.
+        # a Rack adapter from it. Or else we guess which adapter to use and load it.
         if @options[:rackup]
-          rackup_code = File.read(@options[:rackup])
-          server.app  = eval(&quot;Rack::Builder.new {( #{rackup_code}\n )}.to_app&quot;, TOPLEVEL_BINDING, @options[:rackup])
+          server.app = load_rackup_config
         else
-          server.app = Rack::Adapter::Rails.new(@options.merge(:root =&gt; @options[:chdir]))
+          server.app = load_adapter
         end
 
         # If a prefix is required, wrap in Rack URL mapper
@@ -148,6 +152,20 @@ module Thin
           sleep 1 if File.exist?(file) # HACK Give the thread a little time to open the file
           tail_thread
         end
+
+      private
+        def load_adapter
+          adapter = @options[:adapter] || Rack::Adapter.guess(@options[:chdir])
+          log &quot;&gt;&gt; Using #{adapter} adapter&quot;
+          Rack::Adapter.for(adapter, @options)
+        rescue Rack::AdapterNotFound =&gt; e
+          raise InvalidOption, e.message
+        end
+        
+        def load_rackup_config
+          rackup_code = File.read(@options[:rackup])
+          eval(&quot;Rack::Builder.new {( #{rackup_code}\n )}.to_app&quot;, TOPLEVEL_BINDING, @options[:rackup])
+        end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/thin/controllers/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'optparse'
 require 'yaml'
 
-module Thin
+module Thin  
   # CLI runner.
   # Parse options and send command to the correct Controller.
   class Runner
@@ -62,14 +62,19 @@ module Thin
         opts.on(&quot;-p&quot;, &quot;--port PORT&quot;, &quot;use PORT (default: #{@options[:port]})&quot;)          { |port| @options[:port] = port.to_i }
         opts.on(&quot;-S&quot;, &quot;--socket FILE&quot;, &quot;bind to unix domain socket&quot;)                    { |file| @options[:socket] = file }
         opts.on(&quot;-y&quot;, &quot;--swiftiply [KEY]&quot;, &quot;Run using swiftiply&quot;)                       { |key| @options[:swiftiply] = key }
-        opts.on(&quot;-e&quot;, &quot;--environment ENV&quot;, &quot;Rails environment &quot; +                       
-                                           &quot;(default: #{@options[:environment]})&quot;)      { |env| @options[:environment] = env }
+        opts.on(&quot;-A&quot;, &quot;--adapter NAME&quot;, &quot;Rack adapter to use &quot; +                       
+                                        &quot;(default: auto-detected)&quot;)                     { |name| @options[:adapter] = name }
         opts.on(&quot;-c&quot;, &quot;--chdir DIR&quot;, &quot;Change to dir before starting&quot;)                   { |dir| @options[:chdir] = File.expand_path(dir) }
         opts.on(&quot;-r&quot;, &quot;--rackup FILE&quot;, &quot;Load a Rack config file instead of &quot; +
                                        &quot;Rails adapter&quot;)                                 { |file| @options[:rackup] = file }
-        opts.on(      &quot;--prefix PATH&quot;, &quot;Mount the app under PATH (start with /)&quot;)       { |path| @options[:prefix] = path }
         opts.on(      &quot;--stats PATH&quot;, &quot;Mount the Stats adapter under PATH&quot;)             { |path| @options[:stats] = path }
         
+        opts.separator &quot;&quot;
+        opts.separator &quot;Rails options:&quot;
+        opts.on(&quot;-e&quot;, &quot;--environment ENV&quot;, &quot;Rails environment &quot; +                       
+                                           &quot;(default: #{@options[:environment]})&quot;)      { |env| @options[:environment] = env }
+        opts.on(      &quot;--prefix PATH&quot;, &quot;Mount the app under PATH (start with /)&quot;)       { |path| @options[:prefix] = path }
+        
         unless Thin.win? # Daemonizing not supported on Windows
           opts.separator &quot;&quot;
           opts.separator &quot;Daemon options:&quot;
@@ -153,7 +158,11 @@ module Thin
       end
       
       if controller.respond_to?(@command)
-        controller.send(@command, *@arguments)
+        begin
+          controller.send(@command, *@arguments)
+        rescue RunnerError =&gt; e
+          abort e.message
+        end
       else
         abort &quot;Invalid options for command: #{@command}&quot;
       end</diff>
      <filename>lib/thin/runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,12 @@ module Thin
   
   module VERSION #:nodoc:
     MAJOR    = 0
-    MINOR    = 7
-    TINY     = 1
+    MINOR    = 8
+    TINY     = 0
     
     STRING   = [MAJOR, MINOR, TINY].join('.')
     
-    CODENAME = 'Fancy Pants'
+    CODENAME = 'No Name Yet'
     
     RACK     = [0, 3].freeze # Latest Rack version that was tested
   end</diff>
      <filename>lib/thin/version.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,8 @@ describe Controller, 'start' do
                                  :log                  =&gt; 'thin.log',
                                  :timeout              =&gt; 60,
                                  :max_conns            =&gt; 2000,
-                                 :max_persistent_conns =&gt; 1000)
+                                 :max_persistent_conns =&gt; 1000,
+                                 :adapter              =&gt; 'rails')
     
     @server = OpenStruct.new
     @adapter = OpenStruct.new</diff>
      <filename>spec/controllers/controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>spec/rack_rails_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>01b9902d59c795e31931b18a97a7a12cbcdbf305</id>
    </parent>
  </parents>
  <author>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </author>
  <url>http://github.com/macournoyer/thin/commit/af63af254fc3fe63c62d2091e897f6b74aae1706</url>
  <id>af63af254fc3fe63c62d2091e897f6b74aae1706</id>
  <committed-date>2008-03-13T20:58:49-07:00</committed-date>
  <authored-date>2008-03-13T20:58:49-07:00</authored-date>
  <message>* Guess which adapter to use from directory (chdir option)
  or use specified one in 'adapter' option, re #47.</message>
  <tree>0f8b3389a8f6ef6d09a5214a6e62a15910418247</tree>
  <committer>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </committer>
</commit>
