unicorn 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v1.0.1.GIT
4
+ DEF_VER=v1.0.2.GIT
5
5
 
6
6
  LF='
7
7
  '
data/GNUmakefile CHANGED
@@ -169,7 +169,7 @@ NEWS: GIT-VERSION-FILE .manifest
169
169
  $(RAKE) -s news_rdoc > $@+
170
170
  mv $@+ $@
171
171
 
172
- SINCE = 0.991.0
172
+ SINCE = 1.0.0
173
173
  ChangeLog: LOG_VERSION = \
174
174
  $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
175
175
  echo $(GIT_VERSION) || git describe)
@@ -189,7 +189,7 @@ atom = <link rel="alternate" title="Atom feed" href="$(1)" \
189
189
  doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
190
190
  for i in $(man1_rdoc); do echo > $$i; done
191
191
  find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
192
- rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
192
+ rdoc -t "$(shell sed -ne '1s/^= //p' README)"
193
193
  install -m644 COPYING doc/COPYING
194
194
  install -m644 $(shell grep '^[A-Z]' .document) doc/
195
195
  $(MAKE) -C Documentation install-html install-man
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ def tags
15
15
  timefmt = '%Y-%m-%dT%H:%M:%SZ'
16
16
  @tags ||= `git tag -l`.split(/\n/).map do |tag|
17
17
  next if tag == "v0.0.0"
18
- if %r{\Av[\d\.]+\z} =~ tag
18
+ if %r{\Av[\d\.]+} =~ tag
19
19
  header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
20
20
  header = header.split(/\n/)
21
21
  tagger = header.grep(/\Atagger /).first
@@ -168,8 +168,12 @@ task :fm_update do
168
168
  "changelog" => changelog,
169
169
  },
170
170
  }.to_json
171
- Net::HTTP.start(uri.host, uri.port) do |http|
172
- p http.post(uri.path, req, {'Content-Type'=>'application/json'})
171
+ if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
172
+ Net::HTTP.start(uri.host, uri.port) do |http|
173
+ p http.post(uri.path, req, {'Content-Type'=>'application/json'})
174
+ end
175
+ else
176
+ warn "not updating freshmeat for v#{version}"
173
177
  end
174
178
  end
175
179
 
data/lib/unicorn.rb CHANGED
@@ -422,10 +422,12 @@ module Unicorn
422
422
  respawn = false
423
423
  logger.info "gracefully stopping all workers"
424
424
  kill_each_worker(:QUIT)
425
+ self.worker_processes = 0
425
426
  else
426
427
  logger.info "SIGWINCH ignored because we're not daemonized"
427
428
  end
428
429
  when :TTIN
430
+ respawn = true
429
431
  self.worker_processes += 1
430
432
  when :TTOU
431
433
  self.worker_processes -= 1 if self.worker_processes > 0
@@ -486,12 +488,9 @@ module Unicorn
486
488
  # wait for a signal hander to wake us up and then consume the pipe
487
489
  # Wake up every second anyways to run murder_lazy_workers
488
490
  def master_sleep(sec)
489
- begin
490
- IO.select([ SELF_PIPE.first ], nil, nil, sec) or return
491
- SELF_PIPE.first.read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF)
491
+ IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return
492
+ SELF_PIPE[0].read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF)
492
493
  rescue Errno::EAGAIN, Errno::EINTR
493
- break
494
- end while true
495
494
  end
496
495
 
497
496
  def awaken_master
@@ -40,21 +40,24 @@ module Unicorn
40
40
 
41
41
  def initialize(defaults = {}) #:nodoc:
42
42
  self.set = Hash.new(:unset)
43
- use_defaults = defaults.delete(:use_defaults)
43
+ @use_defaults = defaults.delete(:use_defaults)
44
44
  self.config_file = defaults.delete(:config_file)
45
45
 
46
46
  # after_reload is only used by unicorn_rails, unsupported otherwise
47
47
  self.after_reload = defaults.delete(:after_reload)
48
48
 
49
- set.merge!(DEFAULTS) if use_defaults
50
- defaults.each { |key, value| self.send(key, value) }
49
+ set.merge!(DEFAULTS) if @use_defaults
50
+ defaults.each { |key, value| self.__send__(key, value) }
51
51
  Hash === set[:listener_opts] or
52
52
  set[:listener_opts] = Hash.new { |hash,key| hash[key] = {} }
53
53
  Array === set[:listeners] or set[:listeners] = []
54
- reload
54
+ reload(false)
55
55
  end
56
56
 
57
- def reload #:nodoc:
57
+ def reload(merge_defaults = true) #:nodoc:
58
+ if merge_defaults && @use_defaults
59
+ set.merge!(DEFAULTS) if @use_defaults
60
+ end
58
61
  instance_eval(File.read(config_file), config_file) if config_file
59
62
 
60
63
  parse_rackup_file
@@ -361,7 +364,10 @@ module Unicorn
361
364
 
362
365
  # sets the working directory for Unicorn. This ensures SIGUSR2 will
363
366
  # start a new instance of Unicorn in this directory. This may be
364
- # a symlink, a common scenario for Capistrano users.
367
+ # a symlink, a common scenario for Capistrano users. Unlike
368
+ # all other Unicorn configuration directives, this binds immediately
369
+ # for error checking and cannot be undone by unsetting it in the
370
+ # configuration file and reloading.
365
371
  def working_directory(path)
366
372
  # just let chdir raise errors
367
373
  path = File.expand_path(path)
data/lib/unicorn/const.rb CHANGED
@@ -8,8 +8,8 @@ module Unicorn
8
8
  # Symbols did not really improve things much compared to constants.
9
9
  module Const
10
10
 
11
- # The current version of Unicorn, currently 1.0.1
12
- UNICORN_VERSION="1.0.1"
11
+ # The current version of Unicorn, currently 1.0.2
12
+ UNICORN_VERSION="1.0.2"
13
13
 
14
14
  DEFAULT_HOST = "0.0.0.0" # default TCP listen host address
15
15
  DEFAULT_PORT = 8080 # default TCP listen port
@@ -0,0 +1,59 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 8 "SIGTTIN succeeds after SIGWINCH"
4
+
5
+ t_begin "setup and start" && {
6
+ unicorn_setup
7
+ cat >> $unicorn_config <<EOF
8
+ after_fork do |server, worker|
9
+ # test script will block while reading from $fifo,
10
+ File.open("$fifo", "wb") { |fp| fp.syswrite worker.nr.to_s }
11
+ end
12
+ EOF
13
+ unicorn -D -c $unicorn_config pid.ru
14
+ unicorn_wait_start
15
+ test 0 -eq $(cat $fifo) || die "worker.nr != 0"
16
+ }
17
+
18
+ t_begin "read worker pid" && {
19
+ orig_worker_pid=$(curl -sSf http://$listen/)
20
+ test -n "$orig_worker_pid" && kill -0 $orig_worker_pid
21
+ }
22
+
23
+ t_begin "stop all workers" && {
24
+ kill -WINCH $unicorn_pid
25
+ }
26
+
27
+ # we have to do this next step before delivering TTIN
28
+ # signals aren't guaranteed to delivered in order
29
+ t_begin "wait for worker to die" && {
30
+ i=0
31
+ while kill -0 $orig_worker_pid 2>/dev/null
32
+ do
33
+ i=$(( $i + 1 ))
34
+ test $i -lt 600 || die "timed out"
35
+ sleep 1
36
+ done
37
+ }
38
+
39
+ t_begin "start one worker back up" && {
40
+ kill -TTIN $unicorn_pid
41
+ }
42
+
43
+ t_begin "wait for new worker to start" && {
44
+ test 0 -eq $(cat $fifo) || die "worker.nr != 0"
45
+ new_worker_pid=$(curl -sSf http://$listen/)
46
+ test -n "$new_worker_pid" && kill -0 $new_worker_pid
47
+ test $orig_worker_pid -ne $new_worker_pid || \
48
+ die "worker wasn't replaced"
49
+ }
50
+
51
+ t_begin "killing succeeds" && {
52
+ kill $unicorn_pid
53
+ }
54
+
55
+ t_begin "check stderr" && check_stderr
56
+
57
+ dbgcat r_err
58
+
59
+ t_done
@@ -0,0 +1,82 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 9 "reloading unset config resets defaults"
4
+
5
+ t_begin "setup and start" && {
6
+ unicorn_setup
7
+ rtmpfiles unicorn_config_orig before_reload after_reload
8
+ cat $unicorn_config > $unicorn_config_orig
9
+ cat >> $unicorn_config <<EOF
10
+ logger Logger.new(STDOUT)
11
+ preload_app true
12
+ timeout 0x7fffffff
13
+ worker_processes 2
14
+ after_fork { |s,w| }
15
+ \$dump_cfg = lambda { |fp,srv|
16
+ defaults = Unicorn::Configurator::DEFAULTS
17
+ defaults.keys.map { |x| x.to_s }.sort.each do |key|
18
+ next if key =~ %r{\Astd(?:err|out)_path\z}
19
+ key = key.to_sym
20
+ def_value = defaults[key]
21
+ srv_value = srv.__send__(key)
22
+ fp << "#{key}|#{srv_value}|#{def_value}\\n"
23
+ end
24
+ }
25
+ before_fork { |s,w|
26
+ File.open("$before_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
27
+ }
28
+ before_exec { |s| }
29
+ EOF
30
+ unicorn -D -c $unicorn_config env.ru
31
+ unicorn_wait_start
32
+ }
33
+
34
+ t_begin "ensure worker is started" && {
35
+ curl -sSf http://$listen/ > $tmp
36
+ }
37
+
38
+ t_begin "replace config file with original(-ish)" && {
39
+ grep -v ^pid < $unicorn_config_orig > $unicorn_config
40
+ cat >> $unicorn_config <<EOF
41
+ before_fork { |s,w|
42
+ File.open("$after_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
43
+ }
44
+ EOF
45
+ }
46
+
47
+ t_begin "reload signal succeeds" && {
48
+ kill -HUP $unicorn_pid
49
+ while ! egrep '(done|error) reloading' $r_err >/dev/null
50
+ do
51
+ sleep 1
52
+ done
53
+
54
+ grep 'done reloading' $r_err >/dev/null
55
+ }
56
+
57
+ t_begin "ensure worker is started" && {
58
+ curl -sSf http://$listen/ > $tmp
59
+ }
60
+
61
+ t_begin "pid file no longer exists" && {
62
+ if test -f $pid
63
+ then
64
+ die "pid=$pid should not exist"
65
+ fi
66
+ }
67
+
68
+ t_begin "killing succeeds" && {
69
+ kill $unicorn_pid
70
+ }
71
+
72
+ t_begin "check stderr" && {
73
+ check_stderr
74
+ }
75
+
76
+ t_begin "ensure reloading restored settings" && {
77
+ awk < $after_reload -F'|' '
78
+ $1 != "before_fork" && $2 != $3 { print $0; exit(1) }
79
+ '
80
+ }
81
+
82
+ t_done
data/unicorn.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  s.homepage = %q{http://unicorn.bogomips.org/}
37
37
 
38
38
  summary = %q{Rack HTTP server for fast clients and Unix}
39
- s.rdoc_options = [ "-Na", "-t", "Unicorn: #{summary}" ]
39
+ s.rdoc_options = [ "-t", "Unicorn: #{summary}" ]
40
40
  s.require_paths = %w(lib ext)
41
41
  s.rubyforge_project = %q{mongrel}
42
42
  s.summary = summary
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  # *strongly* recommended for security reasons.
50
50
  s.add_dependency(%q<rack>)
51
51
 
52
- s.add_development_dependency('isolate', '~> 2.0.2')
52
+ s.add_development_dependency('isolate', '~> 3.0.0')
53
53
 
54
54
  # s.licenses = %w(GPLv2 Ruby) # licenses= method is not in older RubyGems
55
55
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Unicorn hackers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-13 00:00:00 +00:00
18
+ date: 2010-10-27 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,12 @@ dependencies:
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- hash: 11
43
+ hash: 7
44
44
  segments:
45
- - 2
45
+ - 3
46
+ - 0
46
47
  - 0
47
- - 2
48
- version: 2.0.2
48
+ version: 3.0.0
49
49
  type: :development
50
50
  version_requirements: *id002
51
51
  description: |-
@@ -211,6 +211,8 @@ files:
211
211
  - t/t0006.ru
212
212
  - t/t0007-working_directory_no_embed_cli.sh
213
213
  - t/t0008-back_out_of_upgrade.sh
214
+ - t/t0009-winch_ttin.sh
215
+ - t/t0012-reload-empty-config.sh
214
216
  - t/t0300-rails3-basic.sh
215
217
  - t/t0301-rails3-missing-config-ru.sh
216
218
  - t/t0302-rails3-alt-working_directory.sh
@@ -319,7 +321,6 @@ licenses: []
319
321
 
320
322
  post_install_message:
321
323
  rdoc_options:
322
- - -Na
323
324
  - -t
324
325
  - "Unicorn: Rack HTTP server for fast clients and Unix"
325
326
  require_paths: