diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-10 02:41:46 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-10 02:44:35 -0700 |
commit | bd6b2263869c271113577b88d526c7c2a6f1455d (patch) | |
tree | 096e8f41b6e8b35a0bae7fe14040c2521881f35a /lib/zbatery.rb | |
parent | 5764336aa3785af8a08be7ec7b40846ec139eb6c (diff) | |
download | zbatery-bd6b2263869c271113577b88d526c7c2a6f1455d.tar.gz |
updates for Rainbows! 0.95.0
Rainbows! 0.95.0 made some incompatible changes, so update everything. Unfortunately we have to avoid subclassing here. Tests use isolate now.
Diffstat (limited to 'lib/zbatery.rb')
-rw-r--r-- | lib/zbatery.rb | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/lib/zbatery.rb b/lib/zbatery.rb index 75b03ba..224c9f1 100644 --- a/lib/zbatery.rb +++ b/lib/zbatery.rb @@ -1,4 +1,5 @@ # -*- encoding: binary -*- +# :enddoc: require 'rainbows' module Zbatery @@ -11,7 +12,7 @@ module Zbatery # runs the Zbatery HttpServer with +app+ and +options+ and does # not return until the server has exited. def run(app, options = {}) - HttpServer.new(app, options).start.join + Rainbows::HttpServer.new(app, options).start.join end end @@ -32,7 +33,37 @@ module Zbatery # config files... FORK_HOOK = lambda { |_,_| } - class HttpServer < Rainbows::HttpServer +end + +# :stopdoc: +# override stuff we don't need or can't use portably +module Rainbows + + module Base + # master == worker in our case + def init_worker_process(worker) + after_fork.call(self, worker) + worker.user(*user) if user.kind_of?(Array) && ! worker.switched + build_app! unless preload_app + Rainbows::Response.setup(self.class) + Rainbows::MaxBody.setup + + # avoid spurious wakeups and blocking-accept() with 1.8 green threads + if RUBY_VERSION.to_f < 1.9 + require "io/nonblock" + HttpServer::LISTENERS.each { |l| l.nonblock = true } + end + + logger.info "Zbatery #@use worker_connections=#@worker_connections" + end + end + + # we can't/don't need to do the fchmod heartbeat Unicorn/Rainbows! does + def G.tick + alive + end + + class HttpServer # this class is only used to avoid breaking Unicorn user switching class DeadIO @@ -115,47 +146,20 @@ module Zbatery def before_fork hook = super - hook == FORK_HOOK or + hook == Zbatery::FORK_HOOK or logger.warn "calling before_fork without forking" hook end def after_fork hook = super - hook == FORK_HOOK or + hook == Zbatery::FORK_HOOK or logger.warn "calling after_fork without having forked" hook end end end -# :stopdoc: -# override stuff we don't need or can't use portably -module Rainbows - - module Base - # master == worker in our case - def init_worker_process(worker) - after_fork.call(self, worker) - worker.user(*user) if user.kind_of?(Array) && ! worker.switched - build_app! unless preload_app - - # avoid spurious wakeups and blocking-accept() with 1.8 green threads - if RUBY_VERSION.to_f < 1.9 - require "io/nonblock" - HttpServer::LISTENERS.each { |l| l.nonblock = true } - end - - logger.info "Zbatery #@use worker_connections=#@worker_connections" - end - end - - # we can't/don't need to do the fchmod heartbeat Unicorn/Rainbows! does - def G.tick - alive - end -end - module Unicorn class Configurator |