unicorn 4.3.1 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/GIT-VERSION-GEN +1 -1
  2. data/GNUmakefile +2 -29
  3. data/lib/unicorn.rb +1 -1
  4. data/lib/unicorn/const.rb +1 -1
  5. data/lib/unicorn/http_server.rb +12 -1
  6. data/lib/unicorn/socket_helper.rb +7 -7
  7. data/lib/unicorn/util.rb +1 -0
  8. data/script/isolate_for_tests +0 -18
  9. data/t/listener_names.ru +4 -0
  10. data/t/t0022-listener_names-preload_app.sh +32 -0
  11. data/test/exec/test_exec.rb +72 -86
  12. data/test/unit/test_util.rb +7 -8
  13. metadata +7 -103
  14. data/t/rails3-app/.gitignore +0 -4
  15. data/t/rails3-app/Gemfile +0 -26
  16. data/t/rails3-app/Rakefile +0 -10
  17. data/t/rails3-app/app/controllers/application_controller.rb +0 -4
  18. data/t/rails3-app/app/helpers/application_helper.rb +0 -2
  19. data/t/rails3-app/app/views/layouts/application.html.erb +0 -14
  20. data/t/rails3-app/config.ru +0 -4
  21. data/t/rails3-app/config/application.rb +0 -46
  22. data/t/rails3-app/config/boot.rb +0 -6
  23. data/t/rails3-app/config/database.yml +0 -22
  24. data/t/rails3-app/config/environment.rb +0 -5
  25. data/t/rails3-app/config/environments/development.rb +0 -19
  26. data/t/rails3-app/config/environments/production.rb +0 -42
  27. data/t/rails3-app/config/environments/test.rb +0 -32
  28. data/t/rails3-app/config/initializers/backtrace_silencers.rb +0 -7
  29. data/t/rails3-app/config/initializers/inflections.rb +0 -10
  30. data/t/rails3-app/config/initializers/mime_types.rb +0 -5
  31. data/t/rails3-app/config/initializers/secret_token.rb +0 -7
  32. data/t/rails3-app/config/initializers/session_store.rb +0 -8
  33. data/t/rails3-app/config/locales/en.yml +0 -5
  34. data/t/rails3-app/config/routes.rb +0 -58
  35. data/t/rails3-app/db/seeds.rb +0 -7
  36. data/t/rails3-app/doc/README_FOR_APP +0 -2
  37. data/t/rails3-app/lib/tasks/.gitkeep +0 -0
  38. data/t/rails3-app/public/404.html +0 -1
  39. data/t/rails3-app/public/500.html +0 -1
  40. data/t/rails3-app/public/x.txt +0 -1
  41. data/t/rails3-app/script/rails +0 -9
  42. data/t/rails3-app/test/performance/browsing_test.rb +0 -9
  43. data/t/rails3-app/test/test_helper.rb +0 -13
  44. data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
  45. data/t/t0300-rails3-basic.sh +0 -28
  46. data/t/t0301-rails3-missing-config-ru.sh +0 -33
  47. data/t/t0302-rails3-alt-working_directory.sh +0 -32
  48. data/t/t0303-rails3-alt-working_directory_config.ru.sh +0 -56
  49. data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +0 -52
  50. data/t/test-rails3.sh +0 -27
  51. data/test/rails/app-1.2.3/.gitignore +0 -2
  52. data/test/rails/app-1.2.3/Rakefile +0 -7
  53. data/test/rails/app-1.2.3/app/controllers/application.rb +0 -6
  54. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +0 -36
  55. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +0 -4
  56. data/test/rails/app-1.2.3/config/boot.rb +0 -11
  57. data/test/rails/app-1.2.3/config/database.yml +0 -12
  58. data/test/rails/app-1.2.3/config/environment.rb +0 -13
  59. data/test/rails/app-1.2.3/config/environments/development.rb +0 -9
  60. data/test/rails/app-1.2.3/config/environments/production.rb +0 -5
  61. data/test/rails/app-1.2.3/config/routes.rb +0 -6
  62. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  63. data/test/rails/app-1.2.3/public/404.html +0 -1
  64. data/test/rails/app-1.2.3/public/500.html +0 -1
  65. data/test/rails/app-2.0.2/.gitignore +0 -2
  66. data/test/rails/app-2.0.2/Rakefile +0 -7
  67. data/test/rails/app-2.0.2/app/controllers/application.rb +0 -4
  68. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +0 -36
  69. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +0 -4
  70. data/test/rails/app-2.0.2/config/boot.rb +0 -11
  71. data/test/rails/app-2.0.2/config/database.yml +0 -12
  72. data/test/rails/app-2.0.2/config/environment.rb +0 -17
  73. data/test/rails/app-2.0.2/config/environments/development.rb +0 -8
  74. data/test/rails/app-2.0.2/config/environments/production.rb +0 -5
  75. data/test/rails/app-2.0.2/config/routes.rb +0 -6
  76. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  77. data/test/rails/app-2.0.2/public/404.html +0 -1
  78. data/test/rails/app-2.0.2/public/500.html +0 -1
  79. data/test/rails/app-2.1.2/.gitignore +0 -2
  80. data/test/rails/app-2.1.2/Rakefile +0 -7
  81. data/test/rails/app-2.1.2/app/controllers/application.rb +0 -4
  82. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +0 -36
  83. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +0 -4
  84. data/test/rails/app-2.1.2/config/boot.rb +0 -111
  85. data/test/rails/app-2.1.2/config/database.yml +0 -12
  86. data/test/rails/app-2.1.2/config/environment.rb +0 -17
  87. data/test/rails/app-2.1.2/config/environments/development.rb +0 -7
  88. data/test/rails/app-2.1.2/config/environments/production.rb +0 -5
  89. data/test/rails/app-2.1.2/config/routes.rb +0 -6
  90. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  91. data/test/rails/app-2.1.2/public/404.html +0 -1
  92. data/test/rails/app-2.1.2/public/500.html +0 -1
  93. data/test/rails/app-2.2.2/.gitignore +0 -2
  94. data/test/rails/app-2.2.2/Rakefile +0 -7
  95. data/test/rails/app-2.2.2/app/controllers/application.rb +0 -4
  96. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +0 -36
  97. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +0 -4
  98. data/test/rails/app-2.2.2/config/boot.rb +0 -111
  99. data/test/rails/app-2.2.2/config/database.yml +0 -12
  100. data/test/rails/app-2.2.2/config/environment.rb +0 -17
  101. data/test/rails/app-2.2.2/config/environments/development.rb +0 -7
  102. data/test/rails/app-2.2.2/config/environments/production.rb +0 -5
  103. data/test/rails/app-2.2.2/config/routes.rb +0 -6
  104. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  105. data/test/rails/app-2.2.2/public/404.html +0 -1
  106. data/test/rails/app-2.2.2/public/500.html +0 -1
  107. data/test/rails/test_rails.rb +0 -287
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v4.3.1.GIT
4
+ DEF_VER=v4.4.0.GIT
5
5
 
6
6
  LF='
7
7
  '
data/GNUmakefile CHANGED
@@ -32,16 +32,13 @@ MYLIBS = $(RUBYLIB):$(ISOLATE_LIBS)
32
32
  # dunno how to implement this as concisely in Ruby, and hell, I love awk
33
33
  awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}' 2>/dev/null
34
34
 
35
- rails_vers := $(subst test/rails/app-,,$(wildcard test/rails/app-*))
36
35
  slow_tests := test/unit/test_server.rb test/exec/test_exec.rb \
37
36
  test/unit/test_signals.rb test/unit/test_upload.rb
38
37
  log_suffix = .$(RUBY_ENGINE).$(RUBY_VERSION).log
39
- T_r := $(wildcard test/rails/test*.rb)
40
- T := $(filter-out $(slow_tests) $(T_r), $(wildcard test/*/test*.rb))
38
+ T := $(filter-out $(slow_tests), $(wildcard test/*/test*.rb))
41
39
  T_n := $(shell $(awk_slow) $(slow_tests))
42
40
  T_log := $(subst .rb,$(log_suffix),$(T))
43
41
  T_n_log := $(subst .n,$(log_suffix),$(T_n))
44
- T_r_log := $(subst .r,$(log_suffix),$(T_r))
45
42
  test_prefix = $(CURDIR)/test/$(RUBY_ENGINE)-$(RUBY_VERSION)
46
43
 
47
44
  ext := ext/unicorn_http
@@ -93,7 +90,7 @@ $(slow_tests): $(test_prefix)/.stamp
93
90
  test-integration: $(test_prefix)/.stamp
94
91
  $(MAKE) -C t
95
92
 
96
- test-all: test test-rails test-integration
93
+ test-all: test test-integration
97
94
 
98
95
  TEST_OPTS = -v
99
96
  check_test = grep '0 failures, 0 errors' $(t) >/dev/null
@@ -199,30 +196,6 @@ doc_gz:
199
196
  for i in $(docs); do \
200
197
  gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
201
198
 
202
- rails_git_url = git://github.com/rails/rails.git
203
- rails_git := vendor/rails.git
204
- $(rails_git)/info/cloned-stamp:
205
- git clone --mirror -q $(rails_git_url) $(rails_git)
206
- > $@
207
-
208
- $(rails_git)/info/v2.2.3-stamp: $(rails_git)/info/cloned-stamp
209
- cd $(rails_git) && git fetch
210
- cd $(rails_git) && git rev-parse --verify refs/tags/v2.2.3
211
- > $@
212
-
213
- rails_tests := $(addsuffix .r,$(addprefix $(T_r).,$(rails_vers)))
214
- test-rails: $(rails_tests)
215
- $(T_r).%.r: t = $(addsuffix $(log_suffix),$@)
216
- $(T_r).%.r: rv = $(subst .r,,$(subst $(T_r).,,$@))
217
- $(T_r).%.r: extra = ' 'v$(rv)
218
- $(T_r).%.r: arg = $(T_r)
219
- $(T_r).%.r: export PATH := $(test_prefix)/bin:$(PATH)
220
- $(T_r).%.r: export RUBYLIB := $(test_prefix):$(test_prefix)/lib:$(MYLIBS)
221
- $(T_r).%.r: export UNICORN_RAILS_TEST_VERSION = $(rv)
222
- $(T_r).%.r: export RAILS_GIT_REPO = $(CURDIR)/$(rails_git)
223
- $(T_r).%.r: $(test_prefix)/.stamp $(rails_git)/info/v2.2.3-stamp
224
- $(run_test)
225
-
226
199
  ifneq ($(VERSION),)
227
200
  rfproject := mongrel
228
201
  rfpackage := unicorn
data/lib/unicorn.rb CHANGED
@@ -82,7 +82,7 @@ module Unicorn
82
82
  def self.listener_names
83
83
  Unicorn::HttpServer::LISTENERS.map do |io|
84
84
  Unicorn::SocketHelper.sock_name(io)
85
- end
85
+ end + Unicorn::HttpServer::NEW_LISTENERS
86
86
  end
87
87
 
88
88
  def self.log_error(logger, prefix, exc)
data/lib/unicorn/const.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  # improve things much compared to constants.
9
9
  module Unicorn::Const
10
10
 
11
- UNICORN_VERSION = "4.3.1"
11
+ UNICORN_VERSION = "4.4.0"
12
12
 
13
13
  # default TCP listen host address (0.0.0.0, all interfaces)
14
14
  DEFAULT_HOST = "0.0.0.0"
@@ -28,6 +28,9 @@ class Unicorn::HttpServer
28
28
  # all bound listener sockets
29
29
  LISTENERS = []
30
30
 
31
+ # listeners we have yet to bind
32
+ NEW_LISTENERS = []
33
+
31
34
  # This hash maps PIDs to Workers
32
35
  WORKERS = {}
33
36
 
@@ -134,6 +137,7 @@ class Unicorn::HttpServer
134
137
 
135
138
  self.master_pid = $$
136
139
  build_app! if preload_app
140
+ bind_new_listeners!
137
141
  spawn_missing_workers
138
142
  self
139
143
  end
@@ -738,7 +742,14 @@ class Unicorn::HttpServer
738
742
  @init_listeners << Unicorn::Const::DEFAULT_LISTEN
739
743
  START_CTX[:argv] << "-l#{Unicorn::Const::DEFAULT_LISTEN}"
740
744
  end
741
- config_listeners.each { |addr| listen(addr) }
745
+ NEW_LISTENERS.replace(config_listeners)
746
+ end
747
+
748
+ # call only after calling inherit_listeners!
749
+ # This binds any listeners we did NOT inherit from the parent
750
+ def bind_new_listeners!
751
+ NEW_LISTENERS.each { |addr| listen(addr) }
742
752
  raise ArgumentError, "no listeners" if LISTENERS.empty?
753
+ NEW_LISTENERS.clear
743
754
  end
744
755
  end
@@ -28,7 +28,7 @@ module Unicorn
28
28
  :backlog => 1024,
29
29
 
30
30
  # favor latency over bandwidth savings
31
- :tcp_nopush => false,
31
+ :tcp_nopush => nil,
32
32
  :tcp_nodelay => true,
33
33
  }
34
34
  #:startdoc:
@@ -62,12 +62,12 @@ module Unicorn
62
62
  end
63
63
 
64
64
  val = opt[:tcp_nopush]
65
- val = DEFAULTS[:tcp_nopush] if nil == val
66
- val = val ? 1 : 0
67
- if defined?(TCP_CORK) # Linux
68
- sock.setsockopt(IPPROTO_TCP, TCP_CORK, val)
69
- elsif defined?(TCP_NOPUSH) # TCP_NOPUSH is untested (FreeBSD)
70
- sock.setsockopt(IPPROTO_TCP, TCP_NOPUSH, val)
65
+ unless val.nil?
66
+ if defined?(TCP_CORK) # Linux
67
+ sock.setsockopt(IPPROTO_TCP, TCP_CORK, val)
68
+ elsif defined?(TCP_NOPUSH) # TCP_NOPUSH is lightly tested (FreeBSD)
69
+ sock.setsockopt(IPPROTO_TCP, TCP_NOPUSH, val)
70
+ end
71
71
  end
72
72
 
73
73
  # No good reason to ever have deferred accepts off
data/lib/unicorn/util.rb CHANGED
@@ -7,6 +7,7 @@ module Unicorn::Util
7
7
  append_flags = File::WRONLY | File::APPEND
8
8
 
9
9
  ! fp.closed? &&
10
+ fp.stat.file? &&
10
11
  fp.sync &&
11
12
  (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
12
13
  rescue IOError, Errno::EBADF
@@ -16,9 +16,6 @@ opts = {
16
16
 
17
17
  pid = fork do
18
18
  Isolate.now!(opts) do
19
- if RUBY_VERSION.to_f < 2.0
20
- gem 'sqlite3-ruby', '1.2.5'
21
- end
22
19
  gem 'raindrops', '0.8.0'
23
20
  gem 'kgio-monkey', '0.4.0'
24
21
  gem 'kgio', '2.7.4'
@@ -33,18 +30,3 @@ File.open("#{dst}.#$$", "w") do |fp|
33
30
  fp.puts "ISOLATE_LIBS=#{lib_paths.join(':')}"
34
31
  end
35
32
  File.rename("#{dst}.#$$", dst)
36
-
37
- # pure Ruby gems can be shared across all Rubies
38
- %w(3.0.0).each do |rails_ver|
39
- opts[:path] = "tmp/isolate/rails-#{rails_ver}"
40
- pid = fork do
41
- Isolate.now!(opts) do
42
- gem 'rake', '0.8.7'
43
- gem 'rails', rails_ver
44
- end
45
- end
46
- _, status = Process.waitpid2(pid)
47
- status.success? or abort status.inspect
48
- more = Dir["#{opts[:path]}/gems/*-*/lib"].map { |x| File.expand_path(x) }
49
- lib_paths.concat(more)
50
- end
@@ -0,0 +1,4 @@
1
+ use Rack::ContentLength
2
+ use Rack::ContentType, "text/plain"
3
+ names = Unicorn.listener_names.inspect # rely on preload_app=true
4
+ run(lambda { |_| [ 200, {}, [ names ] ] })
@@ -0,0 +1,32 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+
4
+ # Raindrops::Middleware depends on Unicorn.listener_names,
5
+ # ensure we don't break Raindrops::Middleware when preload_app is true
6
+
7
+ t_plan 4 "Unicorn.listener_names available with preload_app=true"
8
+
9
+ t_begin "setup and startup" && {
10
+ unicorn_setup
11
+ echo preload_app true >> $unicorn_config
12
+ unicorn -E none -D listener_names.ru -c $unicorn_config
13
+ unicorn_wait_start
14
+ }
15
+
16
+ t_begin "read listener names includes listener" && {
17
+ resp=$(curl -sSf http://$listen/)
18
+ ok=false
19
+ t_info "resp=$resp"
20
+ case $resp in
21
+ *\"$listen\"*) ok=true ;;
22
+ esac
23
+ $ok
24
+ }
25
+
26
+ t_begin "killing succeeds" && {
27
+ kill $unicorn_pid
28
+ }
29
+
30
+ t_begin "check stderr" && check_stderr
31
+
32
+ t_done
@@ -229,11 +229,10 @@ EOF
229
229
  pid = xfork { redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port") } }
230
230
  wait_master_ready("test_stderr.#{pid}.log")
231
231
  wait_workers_ready("test_stderr.#{pid}.log", 1)
232
- status = nil
233
- assert_nothing_raised do
234
- Process.kill(sig, pid)
235
- pid, status = Process.waitpid2(pid)
236
- end
232
+
233
+ Process.kill(sig, pid)
234
+ pid, status = Process.waitpid2(pid)
235
+
237
236
  reaped = File.readlines("test_stderr.#{pid}.log").grep(/reaped/)
238
237
  assert_equal 1, reaped.size
239
238
  assert status.exited?
@@ -296,13 +295,13 @@ EOF
296
295
  log = "test_stderr.#{pid}.log"
297
296
  wait_master_ready(log)
298
297
  [ 2, 3].each { |i|
299
- assert_nothing_raised { Process.kill(:TTIN, pid) }
298
+ Process.kill(:TTIN, pid)
300
299
  wait_workers_ready(log, i)
301
300
  }
302
301
  File.truncate(log, 0)
303
302
  reaped = nil
304
303
  [ 2, 1, 0].each { |i|
305
- assert_nothing_raised { Process.kill(:TTOU, pid) }
304
+ Process.kill(:TTOU, pid)
306
305
  DEFAULT_TRIES.times {
307
306
  sleep DEFAULT_RES
308
307
  reaped = File.readlines(log).grep(/reaped.*\s*worker=#{i}$/)
@@ -381,7 +380,7 @@ EOF
381
380
  ucfg.syswrite("listen %(#@addr:#@port)\n")
382
381
  ucfg.syswrite("listen %(#@addr:#{port2})\n")
383
382
  ucfg.syswrite("pid %(#{pid_file})\n")
384
- assert_nothing_raised { Process.kill(:USR2, current_pid) }
383
+ Process.kill(:USR2, current_pid)
385
384
 
386
385
  wait_for_file(old_file)
387
386
  wait_for_file(pid_file)
@@ -393,10 +392,8 @@ EOF
393
392
  assert_equal String, results[0].class
394
393
  assert_equal String, results[1].class
395
394
 
396
- assert_nothing_raised do
397
- Process.kill(:QUIT, current_pid)
398
- Process.kill(:QUIT, new_pid)
399
- end
395
+ Process.kill(:QUIT, current_pid)
396
+ Process.kill(:QUIT, new_pid)
400
397
  end
401
398
 
402
399
  def test_broken_reexec_ru
@@ -446,7 +443,7 @@ EOF
446
443
 
447
444
  # fix the bug
448
445
  File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
449
- assert_nothing_raised { Process.kill(:USR2, current_pid) }
446
+ Process.kill(:USR2, current_pid)
450
447
  wait_for_file(old_file)
451
448
  wait_for_file(pid_file)
452
449
  new_pid = File.read(pid_file).to_i
@@ -455,10 +452,8 @@ EOF
455
452
  results = retry_hit(["http://#{@addr}:#{@port}/"])
456
453
  assert_equal String, results[0].class
457
454
 
458
- assert_nothing_raised do
459
- Process.kill(:QUIT, current_pid)
460
- Process.kill(:QUIT, new_pid)
461
- end
455
+ Process.kill(:QUIT, current_pid)
456
+ Process.kill(:QUIT, new_pid)
462
457
  end
463
458
 
464
459
  def test_unicorn_config_listener_swap
@@ -486,10 +481,8 @@ EOF
486
481
  assert_equal String, results[0].class
487
482
  results = retry_hit(["http://#@addr:#{port_cli}/"])
488
483
  assert_equal String, results[0].class
489
- assert_nothing_raised do
490
- reuse = TCPServer.new(@addr, @port)
491
- reuse.close
492
- end
484
+ reuse = TCPServer.new(@addr, @port)
485
+ reuse.close
493
486
  assert_shutdown(pid)
494
487
  end
495
488
 
@@ -531,7 +524,7 @@ EOF
531
524
  s.syswrite("GET / HTTP/1.0\r\n\r\n")
532
525
  results = ''
533
526
  loop { results << s.sysread(4096) } rescue nil
534
- assert_nothing_raised { s.close }
527
+ s.close
535
528
  assert_equal worker_pid, results.split(/\r\n/).last.to_i
536
529
  results = hit(["http://#@addr:#{port2}/"])
537
530
  assert_equal String, results[0].class
@@ -574,10 +567,10 @@ EOF
574
567
  bf = File.readlines(COMMON_TMP.path).grep(/\bbefore_fork: worker=/)
575
568
  assert_equal 4, bf.size
576
569
  rotate = Tempfile.new('unicorn_rotate')
577
- assert_nothing_raised do
578
- File.rename(COMMON_TMP.path, rotate.path)
579
- Process.kill(:USR1, pid)
580
- end
570
+
571
+ File.rename(COMMON_TMP.path, rotate.path)
572
+ Process.kill(:USR1, pid)
573
+
581
574
  wait_for_file(COMMON_TMP.path)
582
575
  assert File.exist?(COMMON_TMP.path), "#{COMMON_TMP.path} exists"
583
576
  # USR1 should've been passed to all workers
@@ -599,9 +592,10 @@ EOF
599
592
  end
600
593
  assert_equal 5, log.grep(/done reopening logs/).size
601
594
  assert_equal 0, log.grep(/reopening logs\.\.\./).size
602
- assert_nothing_raised { Process.kill(:QUIT, pid) }
603
- status = nil
604
- assert_nothing_raised { pid, status = Process.waitpid2(pid) }
595
+
596
+ Process.kill(:QUIT, pid)
597
+ pid, status = Process.waitpid2(pid)
598
+
605
599
  assert status.success?, "exited successfully"
606
600
  end
607
601
 
@@ -682,23 +676,21 @@ EOF
682
676
  pid = xfork { redirect_test_io { exec($unicorn_bin, "-c#{ucfg.path}") } }
683
677
  wait_for_file(sock_path)
684
678
  assert File.socket?(sock_path)
685
- assert_nothing_raised do
686
- sock = UNIXSocket.new(sock_path)
687
- sock.syswrite("GET / HTTP/1.0\r\n\r\n")
688
- results = sock.sysread(4096)
689
- end
679
+
680
+ sock = UNIXSocket.new(sock_path)
681
+ sock.syswrite("GET / HTTP/1.0\r\n\r\n")
682
+ results = sock.sysread(4096)
683
+
690
684
  assert_equal String, results.class
691
- assert_nothing_raised do
692
- File.unlink(sock_path)
693
- Process.kill(:HUP, pid)
694
- end
685
+ File.unlink(sock_path)
686
+ Process.kill(:HUP, pid)
695
687
  wait_for_file(sock_path)
696
688
  assert File.socket?(sock_path)
697
- assert_nothing_raised do
698
- sock = UNIXSocket.new(sock_path)
699
- sock.syswrite("GET / HTTP/1.0\r\n\r\n")
700
- results = sock.sysread(4096)
701
- end
689
+
690
+ sock = UNIXSocket.new(sock_path)
691
+ sock.syswrite("GET / HTTP/1.0\r\n\r\n")
692
+ results = sock.sysread(4096)
693
+
702
694
  assert_equal String, results.class
703
695
  end
704
696
 
@@ -729,11 +721,11 @@ EOF
729
721
  assert File.exist?(pid_file), "pid_file created"
730
722
  assert_equal pid, File.read(pid_file).to_i
731
723
  assert File.socket?(sock_path), "socket created"
732
- assert_nothing_raised do
733
- sock = UNIXSocket.new(sock_path)
734
- sock.syswrite("GET / HTTP/1.0\r\n\r\n")
735
- results = sock.sysread(4096)
736
- end
724
+
725
+ sock = UNIXSocket.new(sock_path)
726
+ sock.syswrite("GET / HTTP/1.0\r\n\r\n")
727
+ results = sock.sysread(4096)
728
+
737
729
  assert_equal String, results.class
738
730
 
739
731
  # try reloading the config
@@ -745,24 +737,20 @@ EOF
745
737
  new_log.sync = true
746
738
  assert_equal 0, new_log.size
747
739
 
748
- assert_nothing_raised do
749
- ucfg = File.open(ucfg.path, "wb")
750
- ucfg.syswrite("listen \"#{sock_path}\"\n")
751
- ucfg.syswrite("listen \"#{new_sock_path}\"\n")
752
- ucfg.syswrite("pid \"#{pid_file}\"\n")
753
- ucfg.syswrite("logger Logger.new('#{new_log.path}')\n")
754
- ucfg.close
755
- Process.kill(:HUP, pid)
756
- end
740
+ ucfg = File.open(ucfg.path, "wb")
741
+ ucfg.syswrite("listen \"#{sock_path}\"\n")
742
+ ucfg.syswrite("listen \"#{new_sock_path}\"\n")
743
+ ucfg.syswrite("pid \"#{pid_file}\"\n")
744
+ ucfg.syswrite("logger Logger.new('#{new_log.path}')\n")
745
+ ucfg.close
746
+ Process.kill(:HUP, pid)
757
747
 
758
748
  wait_for_file(new_sock_path)
759
749
  assert File.socket?(new_sock_path), "socket exists"
760
750
  @sockets.each do |path|
761
- assert_nothing_raised do
762
- sock = UNIXSocket.new(path)
763
- sock.syswrite("GET / HTTP/1.0\r\n\r\n")
764
- results = sock.sysread(4096)
765
- end
751
+ sock = UNIXSocket.new(path)
752
+ sock.syswrite("GET / HTTP/1.0\r\n\r\n")
753
+ results = sock.sysread(4096)
766
754
  assert_equal String, results.class
767
755
  end
768
756
 
@@ -791,7 +779,7 @@ EOF
791
779
  assert_not_equal pid, new_pid
792
780
  pid, status = Process.waitpid2(pid)
793
781
  assert status.success?, "original process exited successfully"
794
- assert_nothing_raised { Process.kill(0, new_pid) }
782
+ Process.kill(0, new_pid)
795
783
  reexec_usr2_quit_test(new_pid, pid_file)
796
784
  end
797
785
 
@@ -845,11 +833,10 @@ EOF
845
833
  assert $?.success?
846
834
  expect_size = orig_fds.size
847
835
 
848
- assert_nothing_raised do
849
- Process.kill(:USR2, pid)
850
- wait_for_file("#{pid_file}.oldbin")
851
- Process.kill(:QUIT, pid)
852
- end
836
+ Process.kill(:USR2, pid)
837
+ wait_for_file("#{pid_file}.oldbin")
838
+ Process.kill(:QUIT, pid)
839
+
853
840
  wait_for_death(pid)
854
841
 
855
842
  wait_master_ready(log.path)
@@ -865,11 +852,10 @@ EOF
865
852
  assert expect_size >= curr_fds.size, curr_fds.inspect
866
853
  expect_size = curr_fds.size
867
854
 
868
- assert_nothing_raised do
869
- Process.kill(:USR2, pid)
870
- wait_for_file("#{pid_file}.oldbin")
871
- Process.kill(:QUIT, pid)
872
- end
855
+ Process.kill(:USR2, pid)
856
+ wait_for_file("#{pid_file}.oldbin")
857
+ Process.kill(:QUIT, pid)
858
+
873
859
  wait_for_death(pid)
874
860
 
875
861
  wait_master_ready(log.path)
@@ -930,7 +916,7 @@ EOF
930
916
  assert daemon_pid > 0
931
917
  Process.kill(:HUP, daemon_pid)
932
918
  assert_equal '2', r.read(1)
933
- assert_nothing_raised { Process.kill(:TERM, hitter) }
919
+ Process.kill(:TERM, hitter)
934
920
  _, hitter_status = Process.waitpid2(hitter)
935
921
  assert(hitter_status.success?,
936
922
  "invalid: #{hitter_status.inspect} #{File.read(pids.path)}" \
@@ -944,7 +930,7 @@ EOF
944
930
  assert x > 0
945
931
  assert pids[x] > 0
946
932
  }
947
- assert_nothing_raised { Process.kill(:QUIT, daemon_pid) }
933
+ Process.kill(:QUIT, daemon_pid)
948
934
  wait_for_death(daemon_pid)
949
935
  end
950
936
 
@@ -960,12 +946,12 @@ EOF
960
946
  default_listen_lock do
961
947
  res, pid_path = default_listen_setup
962
948
  daemon_pid = File.read(pid_path).to_i
963
- assert_nothing_raised { Process.kill(:HUP, daemon_pid) }
949
+ Process.kill(:HUP, daemon_pid)
964
950
  wait_workers_ready("test_stderr.#$$.log", 1)
965
951
  res2 = hit(["http://#{Unicorn::Const::DEFAULT_LISTEN}/"])
966
952
  assert_match %r{\d+}, res2.first
967
953
  assert res2.first != res.first
968
- assert_nothing_raised { Process.kill(:QUIT, daemon_pid) }
954
+ Process.kill(:QUIT, daemon_pid)
969
955
  wait_for_death(daemon_pid)
970
956
  end
971
957
  end
@@ -974,13 +960,13 @@ EOF
974
960
  default_listen_lock do
975
961
  res, pid_path = default_listen_setup
976
962
  daemon_pid = File.read(pid_path).to_i
977
- assert_nothing_raised {
978
- Process.kill(:USR2, daemon_pid)
979
- wait_for_file("#{pid_path}.oldbin")
980
- wait_for_file(pid_path)
981
- Process.kill(:QUIT, daemon_pid)
982
- wait_for_death(daemon_pid)
983
- }
963
+
964
+ Process.kill(:USR2, daemon_pid)
965
+ wait_for_file("#{pid_path}.oldbin")
966
+ wait_for_file(pid_path)
967
+ Process.kill(:QUIT, daemon_pid)
968
+ wait_for_death(daemon_pid)
969
+
984
970
  daemon_pid = File.read(pid_path).to_i
985
971
  wait_workers_ready("test_stderr.#$$.log", 1)
986
972
  File.truncate("test_stderr.#$$.log", 0)
@@ -989,13 +975,13 @@ EOF
989
975
  assert_match %r{\d+}, res2.first
990
976
  assert res2.first != res.first
991
977
 
992
- assert_nothing_raised { Process.kill(:HUP, daemon_pid) }
978
+ Process.kill(:HUP, daemon_pid)
993
979
  wait_workers_ready("test_stderr.#$$.log", 1)
994
980
  File.truncate("test_stderr.#$$.log", 0)
995
981
  res3 = hit(["http://#{Unicorn::Const::DEFAULT_LISTEN}/"])
996
982
  assert res2.first != res3.first
997
983
 
998
- assert_nothing_raised { Process.kill(:QUIT, daemon_pid) }
984
+ Process.kill(:QUIT, daemon_pid)
999
985
  wait_for_death(daemon_pid)
1000
986
  end
1001
987
  end