unicorn 0.991.0.4.g0cb0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
1
- Unicorn developers:
2
- * Eric Wong
1
+ Unicorn developers (let us know if we forgot you):
2
+ * Eric Wong (BDFL, BOFH)
3
3
  * Suraj N. Kurapati
4
4
  * Andrey Stikheev
5
5
  * Wayne Larsen
6
+ * Iñaki Baz Castillo
7
+ * Augusto Becciu
8
+ * Hongli Lai
6
9
  * ... (help wanted)
7
10
 
8
11
  We would like to thank following folks for helping make Unicorn possible:
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.991.0.GIT
4
+ DEF_VER=v1.0.0.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -8,6 +8,7 @@ MRI = ruby
8
8
  RUBY = ruby
9
9
  RAKE = rake
10
10
  RAGEL = ragel
11
+ RSYNC = rsync
11
12
 
12
13
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
13
14
  @./GIT-VERSION-GEN
@@ -168,7 +169,7 @@ NEWS: GIT-VERSION-FILE .manifest
168
169
  $(RAKE) -s news_rdoc > $@+
169
170
  mv $@+ $@
170
171
 
171
- SINCE = 0.990.0
172
+ SINCE = 0.991.0
172
173
  ChangeLog: LOG_VERSION = \
173
174
  $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
174
175
  echo $(GIT_VERSION) || git describe)
@@ -221,7 +222,7 @@ publish_doc:
221
222
  $(MAKE) doc_gz
222
223
  tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
223
224
  chmod 644 $$(find doc -type f)
224
- rsync -av doc/ unicorn.bogomips.org:/srv/unicorn/
225
+ $(RSYNC) -av doc/ unicorn.bogomips.org:/srv/unicorn/
225
226
  git ls-files | xargs touch
226
227
 
227
228
  # Create gzip variants of the same timestamp as the original so nginx
@@ -120,7 +120,8 @@ module Unicorn::App
120
120
  # ensures rack.input is a file handle that we can redirect stdin to
121
121
  def force_file_input(env)
122
122
  inp = env['rack.input']
123
- if inp.size == 0 # inp could be a StringIO or StringIO-like object
123
+ # inp could be a StringIO or StringIO-like object
124
+ if inp.respond_to?(:size) && inp.size == 0
124
125
  ::File.open('/dev/null', 'rb')
125
126
  else
126
127
  tmp = Unicorn::Util.tmpio
@@ -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 0.991.0
12
- UNICORN_VERSION="0.991.0"
11
+ # The current version of Unicorn, currently 1.0.0
12
+ UNICORN_VERSION="1.0.0"
13
13
 
14
14
  DEFAULT_HOST = "0.0.0.0" # default TCP listen host address
15
15
  DEFAULT_PORT = 8080 # default TCP listen port
@@ -39,6 +39,12 @@ module Unicorn
39
39
  # For Transfer-Encoding:chunked requests, this requires consuming
40
40
  # all of the input stream before returning since there's no other
41
41
  # way to determine the size of the request body beforehand.
42
+ #
43
+ # This method is no longer part of the Rack specification as of
44
+ # Rack 1.2, so its use is not recommended. This method only exists
45
+ # for compatibility with Rack applications designed for Rack 1.1 and
46
+ # earlier. Most applications should only need to call +read+ with a
47
+ # specified +length+ in a loop until it returns +nil+.
42
48
  def size
43
49
  len and return len
44
50
 
@@ -22,7 +22,6 @@ module Unicorn
22
22
 
23
23
  ! fp.closed? &&
24
24
  fp.sync &&
25
- fp.path &&
26
25
  fp.path[0] == ?/ &&
27
26
  (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
28
27
  end
@@ -9,10 +9,18 @@ DLEXT := so
9
9
  # Avoid loading rubygems to speed up tests because gmake is
10
10
  # fork+exec heavy with Ruby.
11
11
  prefix = $(HOME)
12
+
13
+ # XXX clean this up
12
14
  ifeq ($(r192),)
13
15
  ifeq ($(r19),)
14
16
  ifeq ($(rbx),)
15
- RUBY := $(prefix)/bin/ruby
17
+ ifeq ($(r186),)
18
+ RUBY := $(prefix)/bin/ruby
19
+ else
20
+ prefix := $(prefix)/r186-p114
21
+ export PATH := $(prefix)/bin:$(PATH)
22
+ RUBY := $(prefix)/bin/ruby
23
+ endif
16
24
  else
17
25
  prefix := $(prefix)/rbx
18
26
  export PATH := $(prefix)/bin:$(PATH)
@@ -42,7 +50,7 @@ endif
42
50
  # SHELL := /bin/bash -e -o pipefail
43
51
  SHELL := /bin/ksh93 -e -o pipefail
44
52
 
45
- full-test: test-18 test-191 test-192 test-rbx
53
+ full-test: test-18 test-191 test-192 test-rbx test-186
46
54
 
47
55
  # FIXME: keep eye on Rubinius activity and wait for fixes from upstream
48
56
  # so we don't need RBX_SKIP anymore
@@ -50,6 +58,8 @@ test-rbx: export RBX_SKIP := 1
50
58
  test-rbx: export RUBY := $(RUBY)
51
59
  test-rbx:
52
60
  $(MAKE) test test-integration rbx=T 2>&1 |sed -e 's!^!rbx !'
61
+ test-186:
62
+ $(MAKE) test-all r186=1 2>&1 |sed 's!^!1.8.6 !'
53
63
  test-18:
54
64
  $(MAKE) test-all 2>&1 |sed 's!^!1.8 !'
55
65
  test-191:
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+
4
+ t_plan 15 "reopen rotated logs"
5
+
6
+ t_begin "setup and startup" && {
7
+ rtmpfiles curl_out curl_err r_rot
8
+ unicorn_setup
9
+ unicorn -D t0006.ru -c $unicorn_config
10
+ unicorn_wait_start
11
+ }
12
+
13
+ t_begin "ensure server is responsive" && {
14
+ test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
15
+ }
16
+
17
+ t_begin "ensure stderr log is clean" && check_stderr
18
+
19
+ t_begin "external log rotation" && {
20
+ rm -f $r_rot
21
+ mv $r_err $r_rot
22
+ }
23
+
24
+ t_begin "send reopen log signal (USR1)" && {
25
+ kill -USR1 $unicorn_pid
26
+ }
27
+
28
+ t_begin "wait for rotated log to reappear" && {
29
+ nr=60
30
+ while ! test -f $r_err && test $nr -ge 0
31
+ do
32
+ sleep 1
33
+ nr=$(( $nr - 1 ))
34
+ done
35
+ }
36
+
37
+ t_begin "ensure server is still responsive" && {
38
+ test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
39
+ }
40
+
41
+ t_begin "wait for worker to reopen logs" && {
42
+ nr=60
43
+ re="worker=.* done reopening logs"
44
+ while ! grep "$re" < $r_err >/dev/null && test $nr -ge 0
45
+ do
46
+ sleep 1
47
+ nr=$(( $nr - 1 ))
48
+ done
49
+ }
50
+
51
+ dbgcat r_rot
52
+ dbgcat r_err
53
+
54
+ t_begin "ensure no errors from curl" && {
55
+ test ! -s $curl_err
56
+ }
57
+
58
+ t_begin "current server stderr is clean" && check_stderr
59
+
60
+ t_begin "rotated stderr is clean" && {
61
+ check_stderr $r_rot
62
+ }
63
+
64
+ t_begin "server is now writing logs to new stderr" && {
65
+ before_rot=$(wc -c < $r_rot)
66
+ before_err=$(wc -c < $r_err)
67
+ test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
68
+ after_rot=$(wc -c < $r_rot)
69
+ after_err=$(wc -c < $r_err)
70
+ test $after_rot -eq $before_rot
71
+ test $after_err -gt $before_err
72
+ }
73
+
74
+ t_begin "stop server" && {
75
+ kill $unicorn_pid
76
+ }
77
+
78
+ dbgcat r_err
79
+
80
+ t_begin "current server stderr is clean" && check_stderr
81
+ t_begin "rotated stderr is clean" && check_stderr $r_rot
82
+
83
+ t_done
@@ -0,0 +1,13 @@
1
+ use Rack::ContentLength
2
+ use Rack::ContentType, "text/plain"
3
+ run lambda { |env|
4
+
5
+ # our File objects for stderr/stdout should always have #path
6
+ # and be sync=true
7
+ ok = $stderr.sync &&
8
+ $stdout.sync &&
9
+ String === $stderr.path &&
10
+ String === $stdout.path
11
+
12
+ [ 200, {}, [ "#{ok}\n" ] ]
13
+ }
@@ -0,0 +1,44 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+
4
+ t_plan 4 "config.ru inside alt working_directory (no embedded switches)"
5
+
6
+ t_begin "setup and start" && {
7
+ unicorn_setup
8
+ rm -rf $t_pfx.app
9
+ mkdir $t_pfx.app
10
+
11
+ cat > $t_pfx.app/config.ru <<EOF
12
+ use Rack::ContentLength
13
+ use Rack::ContentType, "text/plain"
14
+ run lambda { |env| [ 200, {}, [ "#{\$master_ppid}\\n" ] ] }
15
+ EOF
16
+ # the whole point of this exercise
17
+ echo "working_directory '$t_pfx.app'" >> $unicorn_config
18
+
19
+ # allows ppid to be 1 in before_fork
20
+ echo "preload_app true" >> $unicorn_config
21
+ cat >> $unicorn_config <<\EOF
22
+ before_fork do |server,worker|
23
+ $master_ppid = Process.ppid # should be zero to detect daemonization
24
+ end
25
+ EOF
26
+
27
+ cd /
28
+ unicorn -D -c $unicorn_config
29
+ unicorn_wait_start
30
+ }
31
+
32
+ t_begin "hit with curl" && {
33
+ body=$(curl -sSf http://$listen/)
34
+ }
35
+
36
+ t_begin "killing succeeds" && {
37
+ kill $unicorn_pid
38
+ }
39
+
40
+ t_begin "response body ppid == 1 (daemonized)" && {
41
+ test "$body" -eq 1
42
+ }
43
+
44
+ t_done
@@ -10,8 +10,11 @@ t_plan 5 "Rails 3 (beta) inside alt working_directory (w/ config.ru)"
10
10
 
11
11
  t_begin "setup and start" && {
12
12
  unicorn_setup
13
- rtmpfiles unicorn_config_tmp usock
14
- rm -f $usock
13
+ rtmpfiles unicorn_config_tmp usocket
14
+ if test -e $usocket
15
+ then
16
+ die "unexpected $usocket"
17
+ fi
15
18
  rails3_app=$(cd rails3-app && pwd)
16
19
  rm -rf $t_pfx.app
17
20
  mkdir $t_pfx.app
@@ -22,7 +25,7 @@ t_begin "setup and start" && {
22
25
  unicorn_setup
23
26
  rm $pid
24
27
 
25
- echo "#\\--daemonize --host $host --port $port -l $usock" \
28
+ echo "#\\--daemonize --host $host --port $port -l $usocket" \
26
29
  >> $t_pfx.app/config.ru
27
30
 
28
31
  # we have --host/--port in config.ru instead
@@ -48,7 +51,7 @@ t_begin "static file serving works" && {
48
51
  }
49
52
 
50
53
  t_begin "socket created" && {
51
- test -S $usock
54
+ test -S $usocket
52
55
  }
53
56
 
54
57
  t_begin "killing succeeds" && {
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 5 "Rails 3 (beta) inside alt working_directory (no embedded switches)"
5
+
6
+ t_begin "setup and start" && {
7
+ unicorn_setup
8
+ rtmpfiles unicorn_config_tmp usocket
9
+ if test -e $usocket
10
+ then
11
+ die "unexpected $usocket"
12
+ fi
13
+ rails3_app=$(cd rails3-app && pwd)
14
+ rm -rf $t_pfx.app
15
+ mkdir $t_pfx.app
16
+ cd $t_pfx.app
17
+ ( cd $rails3_app && tar cf - . ) | tar xf -
18
+ $RAKE db:sessions:create
19
+ $RAKE db:migrate
20
+ unicorn_setup
21
+ rm $pid
22
+
23
+ grep -v ^pid $unicorn_config > $unicorn_config_tmp
24
+ echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
25
+ cd /
26
+ unicorn_rails -c $unicorn_config_tmp \
27
+ --daemonize --host $host --port $port -l $usocket
28
+ }
29
+
30
+ t_begin "pids in the right place" && {
31
+ if test -e $pid
32
+ then
33
+ die "pid=$pid not expected"
34
+ fi
35
+
36
+ unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid"
37
+ unicorn_pid=$(cat $unicorn_rails_pid)
38
+ }
39
+
40
+ t_begin "static file serving works" && {
41
+ test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
42
+ }
43
+
44
+ t_begin "socket created" && {
45
+ test -S $usocket
46
+ }
47
+
48
+ t_begin "killing succeeds" && {
49
+ kill $unicorn_pid
50
+ }
51
+
52
+ t_done
@@ -20,10 +20,6 @@ unless try_require('rack')
20
20
  do_test = false
21
21
  end
22
22
 
23
- if ENV['RBX_SKIP']
24
- do_test = false
25
- end
26
-
27
23
  class ExecTest < Test::Unit::TestCase
28
24
  trap(:QUIT, 'IGNORE')
29
25
 
@@ -613,7 +609,7 @@ EOF
613
609
  results = retry_hit(["http://#{@addr}:#{@port}/"])
614
610
  assert_equal String, results[0].class
615
611
  assert_shutdown(pid)
616
- end
612
+ end unless ENV['RBX_SKIP']
617
613
 
618
614
  def test_config_ru_alt_path
619
615
  config_path = "#{@tmpdir}/foo.ru"
@@ -201,6 +201,6 @@ class SignalsTest < Test::Unit::TestCase
201
201
  assert size_before < @tmp.stat.size
202
202
  assert_equal pid, sock.sysread(4096)[/\r\nX-Pid: (\d+)\r\n/, 1].to_i
203
203
  sock.close
204
- end unless ENV['RBX_SKIP']
204
+ end
205
205
 
206
206
  end
@@ -97,7 +97,7 @@ class TestSocketHelper < Test::Unit::TestCase
97
97
  a = bind_listen(tcp_server)
98
98
  assert_equal a.fileno, tcp_server.fileno
99
99
  assert_equal a.fileno, @tcp_listener.fileno
100
- end unless ENV["RBX_SKIP"]
100
+ end
101
101
 
102
102
  def test_bind_listen_unix_rebind
103
103
  test_bind_listen_unix
@@ -139,11 +139,11 @@ class TestSocketHelper < Test::Unit::TestCase
139
139
  assert_equal @tcp_listener.fileno, @tcp_server.fileno
140
140
  assert TCPServer === @tcp_server
141
141
  assert_equal @tcp_listener_name, sock_name(@tcp_server)
142
- end unless ENV["RBX_SKIP"]
142
+ end
143
143
 
144
144
  def test_sock_name
145
145
  test_server_cast
146
146
  sock_name(@unix_server)
147
- end unless ENV["RBX_SKIP"]
147
+ end
148
148
 
149
149
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1081584981
5
- prerelease: true
4
+ hash: 23
5
+ prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 991
9
9
  - 0
10
- - 4
11
- - g0cb0
12
- version: 0.991.0.4.g0cb0
10
+ version: 1.0.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Unicorn hackers
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-06-12 00:00:00 +00:00
18
+ date: 2010-06-17 00:00:00 +00:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -208,10 +206,14 @@ files:
208
206
  - t/t0003-working_directory.sh
209
207
  - t/t0004-working_directory_broken.sh
210
208
  - t/t0005-working_directory_app.rb.sh
209
+ - t/t0006-reopen-logs.sh
210
+ - t/t0006.ru
211
+ - t/t0007-working_directory_no_embed_cli.sh
211
212
  - t/t0300-rails3-basic.sh
212
213
  - t/t0301-rails3-missing-config-ru.sh
213
214
  - t/t0302-rails3-alt-working_directory.sh
214
215
  - t/t0303-rails3-alt-working_directory_config.ru.sh
216
+ - t/t0304-rails3-alt-working_directory_no_embed_cli.sh
215
217
  - t/test-lib.sh
216
218
  - t/test-rails3.sh
217
219
  - test/aggregate.rb
@@ -333,14 +335,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
335
  required_rubygems_version: !ruby/object:Gem::Requirement
334
336
  none: false
335
337
  requirements:
336
- - - ">"
338
+ - - ">="
337
339
  - !ruby/object:Gem::Version
338
- hash: 25
340
+ hash: 3
339
341
  segments:
340
- - 1
341
- - 3
342
- - 1
343
- version: 1.3.1
342
+ - 0
343
+ version: "0"
344
344
  requirements: []
345
345
 
346
346
  rubyforge_project: mongrel