Skip to content

Commit

Permalink
Add detection of config.ru based Rack apps in loader. Makes Rails 3 w…
Browse files Browse the repository at this point in the history
…ork.
  • Loading branch information
macournoyer committed Feb 11, 2010
1 parent 99d9ece commit a094f3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,4 +1,5 @@
== 1.2.6
* Auto-detect and load config.ru files on start. Makes Rails 3 work.
* Fix Thin not obeying to QUIT / TERM signal under Ruby 1.9 [Nate Wiger] [#123 state:resolved]

== 1.2.5 This Is Not A Web Server
Expand Down
6 changes: 6 additions & 0 deletions lib/rack/adapter/loader.rb
Expand Up @@ -8,6 +8,7 @@ class AdapterNotFound < RuntimeError; end
# NOTE: If a framework has a file that is not unique, make sure to place
# it at the end.
ADAPTERS = [
[:rack, 'config.ru'],
[:rails, 'config/environment.rb'],
[:ramaze, 'start.rb'],
[:halcyon, 'runner.ru'],
Expand All @@ -32,6 +33,11 @@ def self.guess(dir)
# Loads an adapter identified by +name+ using +options+ hash.
def self.for(name, options={})
case name.to_sym
when :rack
ENV['RACK_ENV'] = options[:environment]
rackup_code = File.read("config.ru")
return eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, "config.ru")

when :rails
return Rails.new(options.merge(:root => options[:chdir]))

Expand Down

0 comments on commit a094f3a

Please sign in to comment.