diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-01-05 16:10:17 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-01-05 16:10:17 -0800 |
commit | 841f967666292f634c6af485f7ac452f36cc2028 (patch) | |
tree | 4dba86c2fb545a57c7728d1275d276e12d3b26d5 /lib/unicorn.rb | |
parent | 40924ca5f42a5708159ac27b992805f24ecbae9b (diff) | |
parent | fe005f50efc8db5b9f4b2387b3b2c42f12d7c2c0 (diff) | |
download | unicorn-841f967666292f634c6af485f7ac452f36cc2028.tar.gz |
* ready_pipe: launcher: no point in sync-ing $stdin launcher: fix compatibility with other servers clarify errors when listeners fail to bind launcher: descriptive error message on startup failure Avoid leaking ready pipe file descriptor to workers exit with failure if master dies when daemonized
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r-- | lib/unicorn.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 225e00a..69ecf33 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -38,7 +38,7 @@ module Unicorn :before_fork, :after_fork, :before_exec, :logger, :pid, :app, :preload_app, :reexec_pid, :orig_app, :init_listeners, - :master_pid, :config) + :master_pid, :config, :ready_pipe) include ::Unicorn::SocketHelper # prevents IO objects in here from being GC-ed @@ -162,6 +162,7 @@ module Unicorn def initialize(app, options = {}) self.app = app self.reexec_pid = 0 + self.ready_pipe = options.delete(:ready_pipe) self.init_listeners = options[:listeners] ? options[:listeners].dup : [] self.config = Configurator.new(options.merge(:use_defaults => true)) self.listener_opts = {} @@ -327,6 +328,11 @@ module Unicorn trap(:CHLD) { |sig_nr| awaken_master } proc_name 'master' logger.info "master process ready" # test_exec.rb relies on this message + if ready_pipe + ready_pipe.syswrite($$.to_s) + ready_pipe.close rescue nil + self.ready_pipe = nil + end begin loop do reap_all_workers @@ -531,7 +537,11 @@ module Unicorn WORKERS.values.include?(worker_nr) and next worker = Worker.new(worker_nr, Unicorn::Util.tmpio) before_fork.call(self, worker) - WORKERS[fork { worker_loop(worker) }] = worker + WORKERS[fork { + ready_pipe.close if ready_pipe + self.ready_pipe = nil + worker_loop(worker) + }] = worker end end |