unicorn 1.1.7 → 2.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/GIT-VERSION-GEN +1 -1
  2. data/GNUmakefile +14 -5
  3. data/Rakefile +3 -28
  4. data/TODO +7 -0
  5. data/bin/unicorn +9 -13
  6. data/bin/unicorn_rails +12 -14
  7. data/examples/big_app_gc.rb +33 -2
  8. data/ext/unicorn_http/global_variables.h +3 -1
  9. data/ext/unicorn_http/unicorn_http.rl +15 -6
  10. data/lib/unicorn.rb +67 -820
  11. data/lib/unicorn/app/exec_cgi.rb +3 -4
  12. data/lib/unicorn/configurator.rb +20 -25
  13. data/lib/unicorn/const.rb +26 -25
  14. data/lib/unicorn/http_request.rb +64 -57
  15. data/lib/unicorn/http_response.rb +16 -35
  16. data/lib/unicorn/http_server.rb +700 -0
  17. data/lib/unicorn/launcher.rb +4 -3
  18. data/lib/unicorn/oob_gc.rb +50 -61
  19. data/lib/unicorn/socket_helper.rb +4 -4
  20. data/lib/unicorn/tee_input.rb +18 -26
  21. data/lib/unicorn/tmpio.rb +29 -0
  22. data/lib/unicorn/util.rb +51 -85
  23. data/lib/unicorn/worker.rb +40 -0
  24. data/local.mk.sample +0 -9
  25. data/script/isolate_for_tests +43 -0
  26. data/t/GNUmakefile +8 -1
  27. data/t/t0003-working_directory.sh +0 -5
  28. data/t/t0010-reap-logging.sh +55 -0
  29. data/t/t0303-rails3-alt-working_directory_config.ru.sh +0 -5
  30. data/t/test-rails3.sh +1 -1
  31. data/test/exec/test_exec.rb +1 -1
  32. data/test/unit/test_http_parser_ng.rb +11 -0
  33. data/test/unit/test_request.rb +12 -0
  34. data/test/unit/test_response.rb +23 -21
  35. data/test/unit/test_signals.rb +1 -1
  36. data/test/unit/test_tee_input.rb +21 -19
  37. data/unicorn.gemspec +3 -2
  38. metadata +47 -25
  39. data/t/oob_gc.ru +0 -21
  40. data/t/oob_gc_path.ru +0 -21
  41. data/t/t0012-reload-empty-config.sh +0 -82
  42. data/t/t0018-write-on-close.sh +0 -23
  43. data/t/t9001-oob_gc.sh +0 -47
  44. data/t/t9002-oob_gc-path.sh +0 -75
  45. data/t/write-on-close.ru +0 -11
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 = [ "-t", "Unicorn: #{summary}" ]
39
+ s.rdoc_options = [ "-Na", "-t", "Unicorn: #{summary}" ]
40
40
  s.require_paths = %w(lib ext)
41
41
  s.rubyforge_project = %q{mongrel}
42
42
  s.summary = summary
@@ -48,8 +48,9 @@ Gem::Specification.new do |s|
48
48
  # commented out. Nevertheless, upgrading to Rails 2.3.4 or later is
49
49
  # *strongly* recommended for security reasons.
50
50
  s.add_dependency(%q<rack>)
51
+ s.add_dependency(%q<kgio>, '~> 1.2.0')
51
52
 
52
- s.add_development_dependency('isolate', '~> 3.0.0')
53
+ s.add_development_dependency('isolate', '~> 2.1.2')
53
54
 
54
55
  # s.licenses = %w(GPLv2 Ruby) # licenses= method is not in older RubyGems
55
56
  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: 29
5
- prerelease:
4
+ hash: -766259887
5
+ prerelease: true
6
6
  segments:
7
- - 1
8
- - 1
9
- - 7
10
- version: 1.1.7
7
+ - 2
8
+ - 0
9
+ - 0pre1
10
+ version: 2.0.0pre1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Unicorn hackers
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-30 00:00:00 Z
18
+ date: 2010-10-06 00:00:00 +00:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rack
@@ -32,21 +33,37 @@ dependencies:
32
33
  type: :runtime
33
34
  version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency
35
- name: isolate
36
+ name: kgio
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
38
39
  none: false
39
40
  requirements:
40
41
  - - ~>
41
42
  - !ruby/object:Gem::Version
42
- hash: 7
43
+ hash: 31
43
44
  segments:
44
- - 3
45
- - 0
45
+ - 1
46
+ - 2
46
47
  - 0
47
- version: 3.0.0
48
- type: :development
48
+ version: 1.2.0
49
+ type: :runtime
49
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: isolate
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 15
60
+ segments:
61
+ - 2
62
+ - 1
63
+ - 2
64
+ version: 2.1.2
65
+ type: :development
66
+ version_requirements: *id003
50
67
  description: |-
51
68
  Unicorn is an HTTP server for Rack applications designed to only serve
52
69
  fast clients on low-latency, high-bandwidth connections and take
@@ -83,11 +100,14 @@ extra_rdoc_files:
83
100
  - lib/unicorn/const.rb
84
101
  - lib/unicorn/http_request.rb
85
102
  - lib/unicorn/http_response.rb
103
+ - lib/unicorn/http_server.rb
86
104
  - lib/unicorn/launcher.rb
87
105
  - lib/unicorn/oob_gc.rb
88
106
  - lib/unicorn/socket_helper.rb
89
107
  - lib/unicorn/tee_input.rb
108
+ - lib/unicorn/tmpio.rb
90
109
  - lib/unicorn/util.rb
110
+ - lib/unicorn/worker.rb
91
111
  - ext/unicorn_http/unicorn_http.c
92
112
  - ISSUES
93
113
  - Sandbox
@@ -150,14 +170,18 @@ files:
150
170
  - lib/unicorn/const.rb
151
171
  - lib/unicorn/http_request.rb
152
172
  - lib/unicorn/http_response.rb
173
+ - lib/unicorn/http_server.rb
153
174
  - lib/unicorn/launcher.rb
154
175
  - lib/unicorn/oob_gc.rb
155
176
  - lib/unicorn/socket_helper.rb
156
177
  - lib/unicorn/tee_input.rb
178
+ - lib/unicorn/tmpio.rb
157
179
  - lib/unicorn/util.rb
180
+ - lib/unicorn/worker.rb
158
181
  - local.mk.sample
159
182
  - man/man1/unicorn.1
160
183
  - man/man1/unicorn_rails.1
184
+ - script/isolate_for_tests
161
185
  - setup.rb
162
186
  - t/.gitignore
163
187
  - t/GNUmakefile
@@ -168,8 +192,6 @@ files:
168
192
  - t/bin/utee
169
193
  - t/env.ru
170
194
  - t/my-tap-lib.sh
171
- - t/oob_gc.ru
172
- - t/oob_gc_path.ru
173
195
  - t/pid.ru
174
196
  - t/rails3-app/.gitignore
175
197
  - t/rails3-app/Gemfile
@@ -213,19 +235,15 @@ files:
213
235
  - t/t0007-working_directory_no_embed_cli.sh
214
236
  - t/t0008-back_out_of_upgrade.sh
215
237
  - t/t0009-winch_ttin.sh
238
+ - t/t0010-reap-logging.sh
216
239
  - t/t0011-active-unix-socket.sh
217
- - t/t0012-reload-empty-config.sh
218
- - t/t0018-write-on-close.sh
219
240
  - t/t0300-rails3-basic.sh
220
241
  - t/t0301-rails3-missing-config-ru.sh
221
242
  - t/t0302-rails3-alt-working_directory.sh
222
243
  - t/t0303-rails3-alt-working_directory_config.ru.sh
223
244
  - t/t0304-rails3-alt-working_directory_no_embed_cli.sh
224
- - t/t9001-oob_gc.sh
225
- - t/t9002-oob_gc-path.sh
226
245
  - t/test-lib.sh
227
246
  - t/test-rails3.sh
228
- - t/write-on-close.ru
229
247
  - test/aggregate.rb
230
248
  - test/benchmark/README
231
249
  - test/benchmark/dd.ru
@@ -321,11 +339,13 @@ files:
321
339
  - test/unit/test_upload.rb
322
340
  - test/unit/test_util.rb
323
341
  - unicorn.gemspec
342
+ has_rdoc: true
324
343
  homepage: http://unicorn.bogomips.org/
325
344
  licenses: []
326
345
 
327
346
  post_install_message:
328
347
  rdoc_options:
348
+ - -Na
329
349
  - -t
330
350
  - "Unicorn: Rack HTTP server for fast clients and Unix"
331
351
  require_paths:
@@ -343,16 +363,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
363
  required_rubygems_version: !ruby/object:Gem::Requirement
344
364
  none: false
345
365
  requirements:
346
- - - ">="
366
+ - - ">"
347
367
  - !ruby/object:Gem::Version
348
- hash: 3
368
+ hash: 25
349
369
  segments:
350
- - 0
351
- version: "0"
370
+ - 1
371
+ - 3
372
+ - 1
373
+ version: 1.3.1
352
374
  requirements: []
353
375
 
354
376
  rubyforge_project: mongrel
355
- rubygems_version: 1.7.2
377
+ rubygems_version: 1.3.7
356
378
  signing_key:
357
379
  specification_version: 3
358
380
  summary: Rack HTTP server for fast clients and Unix
data/t/oob_gc.ru DELETED
@@ -1,21 +0,0 @@
1
- #\-E none
2
- require 'unicorn/oob_gc'
3
- use Rack::ContentLength
4
- use Rack::ContentType, "text/plain"
5
- use Unicorn::OobGC
6
- $gc_started = false
7
-
8
- # Mock GC.start
9
- def GC.start
10
- ObjectSpace.each_object(BasicSocket) do |x|
11
- next if Unicorn::HttpServer::LISTENERS.include?(x)
12
- x.closed? or abort "not closed #{x}"
13
- end
14
- $gc_started = true
15
- end
16
- run lambda { |env|
17
- if "/gc_reset" == env["PATH_INFO"] && "POST" == env["REQUEST_METHOD"]
18
- $gc_started = false
19
- end
20
- [ 200, {}, [ "#$gc_started\n" ] ]
21
- }
data/t/oob_gc_path.ru DELETED
@@ -1,21 +0,0 @@
1
- #\-E none
2
- require 'unicorn/oob_gc'
3
- use Rack::ContentLength
4
- use Rack::ContentType, "text/plain"
5
- use Unicorn::OobGC, 5, /BAD/
6
- $gc_started = false
7
-
8
- # Mock GC.start
9
- def GC.start
10
- ObjectSpace.each_object(BasicSocket) do |x|
11
- next if Unicorn::HttpServer::LISTENERS.include?(x)
12
- x.closed? or abort "not closed #{x}"
13
- end
14
- $gc_started = true
15
- end
16
- run lambda { |env|
17
- if "/gc_reset" == env["PATH_INFO"] && "POST" == env["REQUEST_METHOD"]
18
- $gc_started = false
19
- end
20
- [ 200, {}, [ "#$gc_started\n" ] ]
21
- }
@@ -1,82 +0,0 @@
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
@@ -1,23 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 4 "write-on-close tests for funky response-bodies"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- unicorn -D -c $unicorn_config write-on-close.ru
8
- unicorn_wait_start
9
- }
10
-
11
- t_begin "write-on-close response body succeeds" && {
12
- test xGoodbye = x"$(curl -sSf http://$listen/)"
13
- }
14
-
15
- t_begin "killing succeeds" && {
16
- kill $unicorn_pid
17
- }
18
-
19
- t_begin "check stderr" && {
20
- check_stderr
21
- }
22
-
23
- t_done
data/t/t9001-oob_gc.sh DELETED
@@ -1,47 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 9 "OobGC test"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- unicorn -D -c $unicorn_config oob_gc.ru
8
- unicorn_wait_start
9
- }
10
-
11
- t_begin "test default interval (4 requests)" && {
12
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
13
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
14
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
15
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
16
- }
17
-
18
- t_begin "GC starting-request returns immediately" && {
19
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
20
- }
21
-
22
- t_begin "GC is started after 5 requests" && {
23
- test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
24
- }
25
-
26
- t_begin "reset GC" && {
27
- test xfalse = x$(curl -vsSf -X POST http://$listen/gc_reset 2>> $tmp)
28
- }
29
-
30
- t_begin "test default interval again (3 requests)" && {
31
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
32
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
33
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
34
- }
35
-
36
- t_begin "GC is started after 5 requests" && {
37
- test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
38
- }
39
-
40
- t_begin "killing succeeds" && {
41
- kill -QUIT $unicorn_pid
42
- }
43
-
44
- t_begin "check_stderr" && check_stderr
45
- dbgcat r_err
46
-
47
- t_done
@@ -1,75 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 12 "OobGC test with limited path"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- unicorn -D -c $unicorn_config oob_gc_path.ru
8
- unicorn_wait_start
9
- }
10
-
11
- t_begin "test default is noop" && {
12
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
13
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
14
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
15
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
16
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
17
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
18
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
19
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
20
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
21
- }
22
-
23
- t_begin "4 bad requests to bump counter" && {
24
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
25
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
26
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
27
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
28
- }
29
-
30
- t_begin "GC-starting request returns immediately" && {
31
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
32
- }
33
-
34
- t_begin "GC was started after 5 requests" && {
35
- test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
36
- }
37
-
38
- t_begin "reset GC" && {
39
- test xfalse = x$(curl -vsSf -X POST http://$listen/gc_reset 2>> $tmp)
40
- }
41
-
42
- t_begin "test default is noop" && {
43
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
44
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
45
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
46
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
47
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
48
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
49
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
50
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
51
- test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
52
- }
53
-
54
- t_begin "4 bad requests to bump counter" && {
55
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
56
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
57
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
58
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
59
- }
60
-
61
- t_begin "GC-starting request returns immediately" && {
62
- test xfalse = x$(curl -vsSf http://$listen/BAD 2>> $tmp)
63
- }
64
-
65
- t_begin "GC was started after 5 requests" && {
66
- test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
67
- }
68
-
69
- t_begin "killing succeeds" && {
70
- kill -QUIT $unicorn_pid
71
- }
72
-
73
- t_begin "check_stderr" && check_stderr
74
-
75
- t_done