unicorn 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/Rakefile +1 -1
- data/bin/unicorn +5 -4
- data/bin/unicorn_rails +1 -1
- data/lib/unicorn.rb +2 -0
- data/lib/unicorn/const.rb +2 -2
- data/lib/unicorn/util.rb +21 -7
- data/t/rails3-app/Gemfile +1 -1
- data/t/t0009-winch_ttin.sh +59 -0
- data/t/test-rails3.sh +1 -1
- metadata +5 -4
data/GIT-VERSION-GEN
CHANGED
data/Rakefile
CHANGED
@@ -207,7 +207,7 @@ task :isolate do
|
|
207
207
|
status.success? or abort status.inspect
|
208
208
|
|
209
209
|
# pure Ruby gems can be shared across all Rubies
|
210
|
-
%w(3.0.0.
|
210
|
+
%w(3.0.0.rc2).each do |rails_ver|
|
211
211
|
opts[:path] = "tmp/isolate/rails-#{rails_ver}"
|
212
212
|
pid = fork { Isolate.now!(opts) { gem 'rails', rails_ver } }
|
213
213
|
_, status = Process.waitpid2(pid)
|
data/bin/unicorn
CHANGED
@@ -10,8 +10,9 @@ host, port = Unicorn::Const::DEFAULT_HOST, Unicorn::Const::DEFAULT_PORT
|
|
10
10
|
set_listener = false
|
11
11
|
|
12
12
|
opts = OptionParser.new("", 24, ' ') do |opts|
|
13
|
-
|
14
|
-
|
13
|
+
cmd = File.basename($0)
|
14
|
+
opts.banner = "Usage: #{cmd} " \
|
15
|
+
"[ruby options] [#{cmd} options] [rackup config file]"
|
15
16
|
|
16
17
|
opts.separator "Ruby options:"
|
17
18
|
|
@@ -39,7 +40,7 @@ opts = OptionParser.new("", 24, ' ') do |opts|
|
|
39
40
|
require library
|
40
41
|
end
|
41
42
|
|
42
|
-
opts.separator "
|
43
|
+
opts.separator "#{cmd} options:"
|
43
44
|
|
44
45
|
# some of these switches exist for rackup command-line compatibility,
|
45
46
|
|
@@ -100,7 +101,7 @@ opts = OptionParser.new("", 24, ' ') do |opts|
|
|
100
101
|
end
|
101
102
|
|
102
103
|
opts.on_tail("-v", "--version", "Show version") do
|
103
|
-
puts "
|
104
|
+
puts "#{cmd} v#{Unicorn::Const::UNICORN_VERSION}"
|
104
105
|
exit
|
105
106
|
end
|
106
107
|
|
data/bin/unicorn_rails
CHANGED
data/lib/unicorn.rb
CHANGED
@@ -423,10 +423,12 @@ module Unicorn
|
|
423
423
|
respawn = false
|
424
424
|
logger.info "gracefully stopping all workers"
|
425
425
|
kill_each_worker(:QUIT)
|
426
|
+
self.worker_processes = 0
|
426
427
|
else
|
427
428
|
logger.info "SIGWINCH ignored because we're not daemonized"
|
428
429
|
end
|
429
430
|
when :TTIN
|
431
|
+
respawn = true
|
430
432
|
self.worker_processes += 1
|
431
433
|
when :TTOU
|
432
434
|
self.worker_processes -= 1 if self.worker_processes > 0
|
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.1.
|
12
|
-
UNICORN_VERSION="1.1.
|
11
|
+
# The current version of Unicorn, currently 1.1.3
|
12
|
+
UNICORN_VERSION="1.1.3"
|
13
13
|
|
14
14
|
DEFAULT_HOST = "0.0.0.0" # default TCP listen host address
|
15
15
|
DEFAULT_PORT = 8080 # default TCP listen port
|
data/lib/unicorn/util.rb
CHANGED
@@ -24,6 +24,8 @@ module Unicorn
|
|
24
24
|
fp.sync &&
|
25
25
|
fp.path[0] == ?/ &&
|
26
26
|
(fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
|
27
|
+
rescue IOError, Errno::EBADF
|
28
|
+
false
|
27
29
|
end
|
28
30
|
|
29
31
|
def chown_logs(uid, gid)
|
@@ -46,20 +48,32 @@ module Unicorn
|
|
46
48
|
ObjectSpace.each_object(File) { |fp| is_log?(fp) and to_reopen << fp }
|
47
49
|
|
48
50
|
to_reopen.each do |fp|
|
49
|
-
orig_st =
|
51
|
+
orig_st = begin
|
52
|
+
fp.stat
|
53
|
+
rescue IOError, Errno::EBADF
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
50
57
|
begin
|
51
58
|
b = File.stat(fp.path)
|
52
59
|
next if orig_st.ino == b.ino && orig_st.dev == b.dev
|
53
60
|
rescue Errno::ENOENT
|
54
61
|
end
|
55
62
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
begin
|
64
|
+
File.open(fp.path, 'a') { |tmpfp| fp.reopen(tmpfp) }
|
65
|
+
fp.sync = true
|
66
|
+
new_st = fp.stat
|
67
|
+
|
68
|
+
# this should only happen in the master:
|
69
|
+
if orig_st.uid != new_st.uid || orig_st.gid != new_st.gid
|
70
|
+
fp.chown(orig_st.uid, orig_st.gid)
|
71
|
+
end
|
72
|
+
|
73
|
+
nr += 1
|
74
|
+
rescue IOError, Errno::EBADF
|
75
|
+
# not much we can do...
|
61
76
|
end
|
62
|
-
nr += 1
|
63
77
|
end
|
64
78
|
|
65
79
|
nr
|
data/t/rails3-app/Gemfile
CHANGED
@@ -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
|
data/t/test-rails3.sh
CHANGED
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
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-
|
18
|
+
date: 2010-08-28 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -211,6 +211,7 @@ 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
|
214
215
|
- t/t0300-rails3-basic.sh
|
215
216
|
- t/t0301-rails3-missing-config-ru.sh
|
216
217
|
- t/t0302-rails3-alt-working_directory.sh
|