unicorn 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +2 -29
- data/lib/unicorn.rb +1 -1
- data/lib/unicorn/const.rb +1 -1
- data/lib/unicorn/http_server.rb +12 -1
- data/lib/unicorn/socket_helper.rb +7 -7
- data/lib/unicorn/util.rb +1 -0
- data/script/isolate_for_tests +0 -18
- data/t/listener_names.ru +4 -0
- data/t/t0022-listener_names-preload_app.sh +32 -0
- data/test/exec/test_exec.rb +72 -86
- data/test/unit/test_util.rb +7 -8
- metadata +7 -103
- data/t/rails3-app/.gitignore +0 -4
- data/t/rails3-app/Gemfile +0 -26
- data/t/rails3-app/Rakefile +0 -10
- data/t/rails3-app/app/controllers/application_controller.rb +0 -4
- data/t/rails3-app/app/helpers/application_helper.rb +0 -2
- data/t/rails3-app/app/views/layouts/application.html.erb +0 -14
- data/t/rails3-app/config.ru +0 -4
- data/t/rails3-app/config/application.rb +0 -46
- data/t/rails3-app/config/boot.rb +0 -6
- data/t/rails3-app/config/database.yml +0 -22
- data/t/rails3-app/config/environment.rb +0 -5
- data/t/rails3-app/config/environments/development.rb +0 -19
- data/t/rails3-app/config/environments/production.rb +0 -42
- data/t/rails3-app/config/environments/test.rb +0 -32
- data/t/rails3-app/config/initializers/backtrace_silencers.rb +0 -7
- data/t/rails3-app/config/initializers/inflections.rb +0 -10
- data/t/rails3-app/config/initializers/mime_types.rb +0 -5
- data/t/rails3-app/config/initializers/secret_token.rb +0 -7
- data/t/rails3-app/config/initializers/session_store.rb +0 -8
- data/t/rails3-app/config/locales/en.yml +0 -5
- data/t/rails3-app/config/routes.rb +0 -58
- data/t/rails3-app/db/seeds.rb +0 -7
- data/t/rails3-app/doc/README_FOR_APP +0 -2
- data/t/rails3-app/lib/tasks/.gitkeep +0 -0
- data/t/rails3-app/public/404.html +0 -1
- data/t/rails3-app/public/500.html +0 -1
- data/t/rails3-app/public/x.txt +0 -1
- data/t/rails3-app/script/rails +0 -9
- data/t/rails3-app/test/performance/browsing_test.rb +0 -9
- data/t/rails3-app/test/test_helper.rb +0 -13
- data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
- data/t/t0300-rails3-basic.sh +0 -28
- data/t/t0301-rails3-missing-config-ru.sh +0 -33
- data/t/t0302-rails3-alt-working_directory.sh +0 -32
- data/t/t0303-rails3-alt-working_directory_config.ru.sh +0 -56
- data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +0 -52
- data/t/test-rails3.sh +0 -27
- data/test/rails/app-1.2.3/.gitignore +0 -2
- data/test/rails/app-1.2.3/Rakefile +0 -7
- data/test/rails/app-1.2.3/app/controllers/application.rb +0 -6
- data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +0 -36
- data/test/rails/app-1.2.3/app/helpers/application_helper.rb +0 -4
- data/test/rails/app-1.2.3/config/boot.rb +0 -11
- data/test/rails/app-1.2.3/config/database.yml +0 -12
- data/test/rails/app-1.2.3/config/environment.rb +0 -13
- data/test/rails/app-1.2.3/config/environments/development.rb +0 -9
- data/test/rails/app-1.2.3/config/environments/production.rb +0 -5
- data/test/rails/app-1.2.3/config/routes.rb +0 -6
- data/test/rails/app-1.2.3/db/.gitignore +0 -0
- data/test/rails/app-1.2.3/public/404.html +0 -1
- data/test/rails/app-1.2.3/public/500.html +0 -1
- data/test/rails/app-2.0.2/.gitignore +0 -2
- data/test/rails/app-2.0.2/Rakefile +0 -7
- data/test/rails/app-2.0.2/app/controllers/application.rb +0 -4
- data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +0 -36
- data/test/rails/app-2.0.2/app/helpers/application_helper.rb +0 -4
- data/test/rails/app-2.0.2/config/boot.rb +0 -11
- data/test/rails/app-2.0.2/config/database.yml +0 -12
- data/test/rails/app-2.0.2/config/environment.rb +0 -17
- data/test/rails/app-2.0.2/config/environments/development.rb +0 -8
- data/test/rails/app-2.0.2/config/environments/production.rb +0 -5
- data/test/rails/app-2.0.2/config/routes.rb +0 -6
- data/test/rails/app-2.0.2/db/.gitignore +0 -0
- data/test/rails/app-2.0.2/public/404.html +0 -1
- data/test/rails/app-2.0.2/public/500.html +0 -1
- data/test/rails/app-2.1.2/.gitignore +0 -2
- data/test/rails/app-2.1.2/Rakefile +0 -7
- data/test/rails/app-2.1.2/app/controllers/application.rb +0 -4
- data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +0 -36
- data/test/rails/app-2.1.2/app/helpers/application_helper.rb +0 -4
- data/test/rails/app-2.1.2/config/boot.rb +0 -111
- data/test/rails/app-2.1.2/config/database.yml +0 -12
- data/test/rails/app-2.1.2/config/environment.rb +0 -17
- data/test/rails/app-2.1.2/config/environments/development.rb +0 -7
- data/test/rails/app-2.1.2/config/environments/production.rb +0 -5
- data/test/rails/app-2.1.2/config/routes.rb +0 -6
- data/test/rails/app-2.1.2/db/.gitignore +0 -0
- data/test/rails/app-2.1.2/public/404.html +0 -1
- data/test/rails/app-2.1.2/public/500.html +0 -1
- data/test/rails/app-2.2.2/.gitignore +0 -2
- data/test/rails/app-2.2.2/Rakefile +0 -7
- data/test/rails/app-2.2.2/app/controllers/application.rb +0 -4
- data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +0 -36
- data/test/rails/app-2.2.2/app/helpers/application_helper.rb +0 -4
- data/test/rails/app-2.2.2/config/boot.rb +0 -111
- data/test/rails/app-2.2.2/config/database.yml +0 -12
- data/test/rails/app-2.2.2/config/environment.rb +0 -17
- data/test/rails/app-2.2.2/config/environments/development.rb +0 -7
- data/test/rails/app-2.2.2/config/environments/production.rb +0 -5
- data/test/rails/app-2.2.2/config/routes.rb +0 -6
- data/test/rails/app-2.2.2/db/.gitignore +0 -0
- data/test/rails/app-2.2.2/public/404.html +0 -1
- data/test/rails/app-2.2.2/public/500.html +0 -1
- data/test/rails/test_rails.rb +0 -287
data/GIT-VERSION-GEN
CHANGED
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
|
-
|
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-
|
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
data/lib/unicorn/const.rb
CHANGED
data/lib/unicorn/http_server.rb
CHANGED
@@ -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
|
-
|
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 =>
|
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
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
data/script/isolate_for_tests
CHANGED
@@ -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
|
data/t/listener_names.ru
ADDED
@@ -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
|
data/test/exec/test_exec.rb
CHANGED
@@ -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
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
397
|
-
|
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
|
-
|
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
|
-
|
459
|
-
|
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
|
-
|
490
|
-
|
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
|
-
|
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
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
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
|
-
|
603
|
-
|
604
|
-
|
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
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
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
|
-
|
692
|
-
|
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
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
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
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
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
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
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
|
-
|
762
|
-
|
763
|
-
|
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
|
-
|
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
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
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
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
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
|
-
|
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
|
-
|
984
|
+
Process.kill(:QUIT, daemon_pid)
|
999
985
|
wait_for_death(daemon_pid)
|
1000
986
|
end
|
1001
987
|
end
|