summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-18 15:00:08 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-18 15:00:08 -0700
commit82167684e868e4e501713d2c03b096db6daab0a0 (patch)
tree183e97c5ecbdcb4ae81d2d55ad84927150e66670
parent1aa156429fd926162a112d327dc394cb9772c79c (diff)
Allow the --rainbows/-R command-line option to be passed to
activate Rainbows!!!1
-rw-r--r--Manifest1
-rwxr-xr-xbin/unicorn2
-rwxr-xr-xbin/unicorn_rails2
-rw-r--r--lib/unicorn.rb4
-rw-r--r--lib/unicorn/rainbows.rb2
-rw-r--r--lib/unicorn/rainbows/request.rb11
6 files changed, 20 insertions, 2 deletions
diff --git a/Manifest b/Manifest
index 9aa19e3..902431e 100644
--- a/Manifest
+++ b/Manifest
@@ -37,6 +37,7 @@ lib/unicorn/const.rb
 lib/unicorn/http_request.rb
 lib/unicorn/http_response.rb
 lib/unicorn/launcher.rb
+lib/unicorn/rainbows.rb
 lib/unicorn/socket_helper.rb
 lib/unicorn/tee_input.rb
 lib/unicorn/util.rb
diff --git a/bin/unicorn b/bin/unicorn
index 8847e81..95c15ba 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -85,6 +85,8 @@ opts = OptionParser.new("", 24, '  ') do |opts|
     options[:config_file] = File.expand_path(f)
   end
 
+  opts.on("-R", "--rainbows") { options[:rainbows] = true }
+
   # I'm avoiding Unicorn-specific config options on the command-line.
   # IMNSHO, config options on the command-line are redundant given
   # config files and make things unnecessarily complicated with multiple
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index 1fbc0e2..866833b 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -83,6 +83,8 @@ opts = OptionParser.new("", 24, '  ') do |opts|
     ENV['RAILS_RELATIVE_URL_ROOT'] = map_path = v
   end
 
+  opts.on("-R", "--rainbows") { options[:rainbows] = true }
+
   # I'm avoiding Unicorn-specific config options on the command-line.
   # IMNSHO, config options on the command-line are redundant given
   # config files and make things unnecessarily complicated with multiple
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index b185b25..1bd88d3 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -12,6 +12,7 @@ module Unicorn
   autoload :Configurator, 'unicorn/configurator'
   autoload :TeeInput, 'unicorn/tee_input'
   autoload :Util, 'unicorn/util'
+  autoload :Rainbows, 'unicorn/rainbows'
 
   Z = '' # the stock empty string we use everywhere...
   Z.force_encoding(Encoding::BINARY) if Z.respond_to?(:force_encoding)
@@ -19,7 +20,8 @@ module Unicorn
 
   class << self
     def run(app, options = {})
-      HttpServer.new(app, options).start.join
+      klass = options.delete(:rainbows) ? Rainbows : HttpServer
+      klass.new(app, options).start.join
     end
   end
 
diff --git a/lib/unicorn/rainbows.rb b/lib/unicorn/rainbows.rb
index 33064c9..39fe29c 100644
--- a/lib/unicorn/rainbows.rb
+++ b/lib/unicorn/rainbows.rb
@@ -62,7 +62,7 @@ module Unicorn
       trap(:USR1) { reopen_worker_logs(worker.nr) }
       trap(:QUIT) { alive = false; LISTENERS.each { |s| s.close rescue nil } }
       [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
-      logger.info "worker=#{worker.nr} ready"
+      logger.info "worker=#{worker.nr} ready with Rainbows"
 
       begin
         Actor.spawn(ready.accept) { |s| process_client(s) }
diff --git a/lib/unicorn/rainbows/request.rb b/lib/unicorn/rainbows/request.rb
new file mode 100644
index 0000000..d2c2c65
--- /dev/null
+++ b/lib/unicorn/rainbows/request.rb
@@ -0,0 +1,11 @@
+module Unicorn
+  class Rainbows
+    class HttpRequest
+
+      def initialize
+      end
+
+    end
+  end
+end
+