lib/zbatery.rb in zbatery-3.4.0 vs lib/zbatery.rb in zbatery-4.0.0

- old
+ new

@@ -2,21 +2,12 @@ # :enddoc: require 'rainbows' Rainbows.forked = true module Zbatery - VERSION = "3.4.0" + VERSION = "4.0.0" - class << self - - # runs the Zbatery HttpServer with +app+ and +options+ and does - # not return until the server has exited. - def run(app, options = {}) - Rainbows::HttpServer.new(app, options).start.join - end - end - Rainbows::Const::RACK_DEFAULTS["SERVER_SOFTWARE"] = "Zbatery #{VERSION}" # we don't actually fork workers, but allow using the # {before,after}_fork hooks found in Unicorn/Rainbows! # config files... @@ -31,11 +22,11 @@ # 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::Response.setup Rainbows::MaxBody.setup Rainbows::ProcessClient.const_set(:APP, @app) logger.info "Zbatery #@use worker_connections=#@worker_connections" end @@ -46,16 +37,10 @@ alive end class HttpServer - # this class is only used to avoid breaking Unicorn user switching - class DeadIO - def chown(*args); end - alias fcntl chown - end - # only used if no concurrency model is specified def worker_loop(worker) init_worker_process(worker) begin ret = IO.select(LISTENERS, nil, nil, nil) and @@ -70,10 +55,11 @@ end while Rainbows.alive end # no-op def maintain_worker_count; end + def spawn_missing_workers; end def init_self_pipe!; end # can't just do a graceful exit if reopening logs fails, so we just # continue on... def reopen_logs @@ -105,10 +91,10 @@ ready_pipe.syswrite($$.to_s) ready_pipe.close self.ready_pipe = nil end extend(Rainbows.const_get(@use)) - worker = Worker.new(0, DeadIO.new) + worker = Worker.new(0) before_fork.call(self, worker) worker_loop(worker) # runs forever end def stop(graceful = true)