From 8d626390cecb0134ad2d43a055eacd7856ab44f1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 02:02:11 +0000 Subject: fix delays in signal handling There is no need to loop in the master_sleep method at all, as the rest of the code is designed to function even on interrupted sleeps. This change is included as part of a larger cleanup in master. (commit bdc79712e5ac53d39c51e80dfe50aff950e5053f). From maint: (cherry picked from commit 10037f2aabb3fab4296fc90c615e7caa9f4a9b53) Conflicts: lib/unicorn.rb --- lib/unicorn.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 8f490bb..735354f 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -489,12 +489,9 @@ module Unicorn # wait for a signal hander to wake us up and then consume the pipe # Wake up every second anyways to run murder_lazy_workers def master_sleep(sec) - begin - IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return - SELF_PIPE[0].read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF) + IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return + SELF_PIPE[0].read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF) rescue Errno::EAGAIN, Errno::EINTR - break - end while true end def awaken_master -- cgit v1.2.3-24-ge0c7 From 1ad510d645e0c84c8d352ac0deaeefa75240ea94 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 19:32:55 +0000 Subject: Rakefile: don't post freshmeat on empty changelogs We don't want to flood or monopolize freshmeat. --- Rakefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index c140b89..f345618 100644 --- a/Rakefile +++ b/Rakefile @@ -168,8 +168,12 @@ task :fm_update do "changelog" => changelog, }, }.to_json - Net::HTTP.start(uri.host, uri.port) do |http| - p http.post(uri.path, req, {'Content-Type'=>'application/json'}) + if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z} + Net::HTTP.start(uri.host, uri.port) do |http| + p http.post(uri.path, req, {'Content-Type'=>'application/json'}) + end + else + warn "not updating freshmeat for v#{version}" end end -- cgit v1.2.3-24-ge0c7 From 5a220b889ba9e56ea9fea24bbae4e38e7d7e31d5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 6 Oct 2010 01:27:45 +0000 Subject: Rakefile: capture prerelease tags Since we do those, now. (cherry picked from commit 1d1a2b1bd5bdd89f774f19bf8ad24c2f5f8a2d4c) --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index f345618..15a0f61 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ def tags timefmt = '%Y-%m-%dT%H:%M:%SZ' @tags ||= `git tag -l`.split(/\n/).map do |tag| next if tag == "v0.0.0" - if %r{\Av[\d\.]+\z} =~ tag + if %r{\Av[\d\.]+} =~ tag header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) header = header.split(/\n/) tagger = header.grep(/\Atagger /).first -- cgit v1.2.3-24-ge0c7 From 19b0ac826b9afd283f4cf5c57d554d20f24d2b46 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 12:46:46 -0700 Subject: configurator: use "__send__" instead of "send" It's less ambiguous since this is a network server after all. (cherry picked from commit f62c5850d7d17d7b5e301a494f8bdf5be3674411) --- lib/unicorn/configurator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 6be6fbd..1c5ca1a 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -43,7 +43,7 @@ class Unicorn::Configurator < Struct.new(:set, :config_file, :after_reload) self.after_reload = defaults.delete(:after_reload) set.merge!(DEFAULTS) if use_defaults - defaults.each { |key, value| self.send(key, value) } + defaults.each { |key, value| self.__send__(key, value) } Hash === set[:listener_opts] or set[:listener_opts] = Hash.new { |hash,key| hash[key] = {} } Array === set[:listeners] or set[:listeners] = [] -- cgit v1.2.3-24-ge0c7 From cb2c86aaa692c02f0e1810facfe244f28ddb36ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 13:51:12 -0700 Subject: configurator: reloading with unset values restores default If a configuration directive is set at startup and later unset, it correctly restores the original default value as if it had never been set in the first place. This applies to the majority of the configuration values with a few exceptions: * This only applies to stderr_path and stdout_path when daemonized (the usual case, they'll be redirected to "/dev/null"). When NOT daemonized, we cannot easily redirect back to the original stdout/stderr destinations. * Unsetting working_directory does not restore the original working directory where Unicorn was started. As far as we can tell unsetting this after setting it is rarely desirable and greatly increases the probability of user error. (cherry picked from commit 51b2b90284000aee8d79b37a5406173c45ae212d) --- lib/unicorn/configurator.rb | 16 ++++++--- t/t0012-reload-empty-config.sh | 82 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 5 deletions(-) create mode 100755 t/t0012-reload-empty-config.sh diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 1c5ca1a..fb37c56 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -36,21 +36,24 @@ class Unicorn::Configurator < Struct.new(:set, :config_file, :after_reload) def initialize(defaults = {}) #:nodoc: self.set = Hash.new(:unset) - use_defaults = defaults.delete(:use_defaults) + @use_defaults = defaults.delete(:use_defaults) self.config_file = defaults.delete(:config_file) # after_reload is only used by unicorn_rails, unsupported otherwise self.after_reload = defaults.delete(:after_reload) - set.merge!(DEFAULTS) if use_defaults + set.merge!(DEFAULTS) if @use_defaults defaults.each { |key, value| self.__send__(key, value) } Hash === set[:listener_opts] or set[:listener_opts] = Hash.new { |hash,key| hash[key] = {} } Array === set[:listeners] or set[:listeners] = [] - reload + reload(false) end - def reload #:nodoc: + def reload(merge_defaults = true) #:nodoc: + if merge_defaults && @use_defaults + set.merge!(DEFAULTS) if @use_defaults + end instance_eval(File.read(config_file), config_file) if config_file parse_rackup_file @@ -392,7 +395,10 @@ class Unicorn::Configurator < Struct.new(:set, :config_file, :after_reload) # sets the working directory for Unicorn. This ensures SIGUSR2 will # start a new instance of Unicorn in this directory. This may be - # a symlink, a common scenario for Capistrano users. + # a symlink, a common scenario for Capistrano users. Unlike + # all other Unicorn configuration directives, this binds immediately + # for error checking and cannot be undone by unsetting it in the + # configuration file and reloading. def working_directory(path) # just let chdir raise errors path = File.expand_path(path) diff --git a/t/t0012-reload-empty-config.sh b/t/t0012-reload-empty-config.sh new file mode 100755 index 0000000..c18c030 --- /dev/null +++ b/t/t0012-reload-empty-config.sh @@ -0,0 +1,82 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 9 "reloading unset config resets defaults" + +t_begin "setup and start" && { + unicorn_setup + rtmpfiles unicorn_config_orig before_reload after_reload + cat $unicorn_config > $unicorn_config_orig + cat >> $unicorn_config < $tmp +} + +t_begin "replace config file with original(-ish)" && { + grep -v ^pid < $unicorn_config_orig > $unicorn_config + cat >> $unicorn_config </dev/null + do + sleep 1 + done + + grep 'done reloading' $r_err >/dev/null +} + +t_begin "ensure worker is started" && { + curl -sSf http://$listen/ > $tmp +} + +t_begin "pid file no longer exists" && { + if test -f $pid + then + die "pid=$pid should not exist" + fi +} + +t_begin "killing succeeds" && { + kill $unicorn_pid +} + +t_begin "check stderr" && { + check_stderr +} + +t_begin "ensure reloading restored settings" && { + awk < $after_reload -F'|' ' +$1 != "before_fork" && $2 != $3 { print $0; exit(1) } +' +} + +t_done -- cgit v1.2.3-24-ge0c7 From 427862fa9884aae96c9d39f35e09be292d2928ab Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 23:09:19 +0000 Subject: gemspec: depend on Isolate 3.0.0 for dev No reason to not use the latest and greatest! (cherry picked from commit 570a57c07fd8c3d24b7337637e0dd30136b3a11a) Conflicts: unicorn.gemspec --- unicorn.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unicorn.gemspec b/unicorn.gemspec index 44a6d56..ccf4e09 100644 --- a/unicorn.gemspec +++ b/unicorn.gemspec @@ -49,7 +49,7 @@ Gem::Specification.new do |s| # *strongly* recommended for security reasons. s.add_dependency(%q) - s.add_development_dependency('isolate', '~> 2.0.2') + s.add_development_dependency('isolate', '~> 3.0.0') # s.licenses = %w(GPLv2 Ruby) # licenses= method is not in older RubyGems end -- cgit v1.2.3-24-ge0c7 From 7207a8cbd1f0fbfd8c8543fd21e4f04ecff6e2f5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 23:07:42 +0000 Subject: doc: stop using deprecated rdoc CLI options -N and -a switches no longer exist in rdoc 2.5 (cherry picked from commit 054c7df93db61839648925cfd881ae880709a210) --- GNUmakefile | 2 +- unicorn.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 3354ff1..a3b761a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -189,7 +189,7 @@ atom = $$i; done find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';' - rdoc -a -t "$(shell sed -ne '1s/^= //p' README)" + rdoc -t "$(shell sed -ne '1s/^= //p' README)" install -m644 COPYING doc/COPYING install -m644 $(shell grep '^[A-Z]' .document) doc/ $(MAKE) -C Documentation install-html install-man diff --git a/unicorn.gemspec b/unicorn.gemspec index ccf4e09..973ca09 100644 --- a/unicorn.gemspec +++ b/unicorn.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |s| s.homepage = %q{http://unicorn.bogomips.org/} summary = %q{Rack HTTP server for fast clients and Unix} - s.rdoc_options = [ "-Na", "-t", "Unicorn: #{summary}" ] + s.rdoc_options = [ "-t", "Unicorn: #{summary}" ] s.require_paths = %w(lib ext) s.rubyforge_project = %q{mongrel} s.summary = summary -- cgit v1.2.3-24-ge0c7 From 7f3ebe9213e09932cd0e8a2a82bfe2dd5430a824 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Oct 2010 23:29:55 +0000 Subject: unicorn 1.1.5 This maintenance release fixes several long-standing but recently-noticed bugs. SIGHUP reloading now correctly restores default values if they're erased or commented-out in the Unicorn configuration file. Delays/slowdowns in signal handling since 0.990 are fixed, too. --- GIT-VERSION-GEN | 2 +- lib/unicorn/const.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 755e132..9e60ee9 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.1.4.GIT +DEF_VER=v1.1.5.GIT LF=' ' diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb index a166780..2f0b106 100644 --- a/lib/unicorn/const.rb +++ b/lib/unicorn/const.rb @@ -8,8 +8,8 @@ module Unicorn # Symbols did not really improve things much compared to constants. module Const - # The current version of Unicorn, currently 1.1.4 - UNICORN_VERSION="1.1.4" + # The current version of Unicorn, currently 1.1.5 + UNICORN_VERSION="1.1.5" DEFAULT_HOST = "0.0.0.0" # default TCP listen host address DEFAULT_PORT = 8080 # default TCP listen port -- cgit v1.2.3-24-ge0c7