diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-04 20:52:36 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-04 20:55:37 -0700 |
commit | b5a0a2cce2c10ade80c1bc9a54d73194bb520776 (patch) | |
tree | 637fe3f1c35556dc1055926a432fbc4e2ec8b8e0 | |
parent | e8eb252f64c94eb57532ef3de55d28e5d23e3cd8 (diff) | |
download | rainbows-b5a0a2cce2c10ade80c1bc9a54d73194bb520776.tar.gz |
Only inject this method into Unicorn::Configurator to avoid polluting the namespace.
-rw-r--r-- | lib/rainbows.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 04be9b4..4ba4b97 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -1,11 +1,6 @@ # -*- encoding: binary -*- require 'unicorn' -def Rainbows!(&block) - block_given? or raise ArgumentError, "Rainbows! requires a block" - Rainbows::HttpServer.setup(block) -end - module Rainbows require 'rainbows/const' @@ -14,11 +9,31 @@ module Rainbows require 'rainbows/base' class << self + + # runs the Rainbows! HttpServer with +app+ and +options+ and does + # not return until the server has exited. def run(app, options = {}) HttpServer.new(app, options).start.join end end + # configures Rainbows! with a given concurrency model to +use+ and + # a +worker_connections+ upper-bound. This method may be called + # inside a Unicorn/Rainbows configuration file: + # + # Rainbows! do + # use :Revactor # this may also be :ThreadSpawn or :ThreadPool + # worker_connections 128 + # end + # + # See the documentation for the respective Revactor, ThreadSpawn, + # and ThreadPool classes for descriptions and recommendations for + # each of them. + def Rainbows!(&block) + block_given? or raise ArgumentError, "Rainbows! requires a block" + HttpServer.setup(block) + end + # maps models to default worker counts, default worker count numbers are # pretty arbitrary and tuning them to your application and hardware is # highly recommended @@ -33,3 +48,6 @@ module Rainbows end end + +# inject the Rainbows! method into Unicorn::Configurator +Unicorn::Configurator.class_eval { include Rainbows } |