unicorn-wrangler 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/unicorn/wrangler.rb +6 -1
- data/lib/unicorn/wrangler/version.rb +1 -1
- data/spec/lib/unicorn/wrangler_spec.rb +29 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71bee49e7a7465805c10eee3e28597ed216727b6
|
4
|
+
data.tar.gz: f19c67dbc73080d46de86a01a4142868569745ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa20517db73067e8dbaaa3aadb35c355c3e9f8e5abe2ebdde07c64b6c87cf935893271a43ce5535475de6210bdee98c0b674ca42f8c6677b89948ca76985d35
|
7
|
+
data.tar.gz: cf19b3a4c8d5b1861aee2d48356ab0bc1c4af868b3ea1231e2d1b3d3a74e668bcc6fd6e15c27690647b60e6d538d90a65ae8bd444c578da7c523e2cdc4f47457
|
data/lib/unicorn/wrangler.rb
CHANGED
@@ -11,7 +11,11 @@ module Unicorn
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def start
|
14
|
-
trap_signals(:
|
14
|
+
trap_signals(:HUP) { restart_unicorn }
|
15
|
+
trap_signals(:QUIT, :INT, :TERM) do |signal|
|
16
|
+
Process.kill signal, unicorn_pid if unicorn_running?
|
17
|
+
exit
|
18
|
+
end
|
15
19
|
|
16
20
|
if unicorn_running?
|
17
21
|
restart_unicorn
|
@@ -31,6 +35,7 @@ module Unicorn
|
|
31
35
|
def trap_signals(*signals, &block)
|
32
36
|
signals.map(&:to_s).each do |signal|
|
33
37
|
trap(signal) do
|
38
|
+
puts "unicorn-wrangler #{Process.pid} received #{signal} (managing #{unicorn_pid})"
|
34
39
|
block.call signal
|
35
40
|
end
|
36
41
|
end
|
@@ -54,25 +54,47 @@ describe Unicorn::Wrangler do
|
|
54
54
|
start_wrangler
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
context 'on receiving HUP signal' do
|
58
|
+
before do
|
59
|
+
@original_pid = unicorn_pid
|
60
|
+
@original_response = perform_request
|
61
|
+
Process.kill :HUP, @wrangler_pid
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'restarts unicorn on startup' do
|
65
|
+
sleep 3
|
66
|
+
unicorn_pid.should_not eql(@original_pid)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'continues serving requests from both unicorns' do
|
70
|
+
20.times.map { sleep 0.1; perform_request }.uniq.size.should eql(2)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'stops serving requests from original unicorn' do
|
74
|
+
sleep 3
|
75
|
+
perform_request.should_not eql(@original_response)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'quits on receiving QUIT signal' do
|
58
80
|
Process.kill 'QUIT', @wrangler_pid
|
59
81
|
sleep 1
|
60
82
|
wrangler_running?.should_not be_true
|
61
|
-
unicorn_running?.
|
83
|
+
unicorn_running?.should_not be_true
|
62
84
|
end
|
63
85
|
|
64
|
-
it 'quits
|
86
|
+
it 'quits on receiving TERM signal' do
|
65
87
|
Process.kill 'TERM', @wrangler_pid
|
66
88
|
sleep 1
|
67
89
|
wrangler_running?.should_not be_true
|
68
|
-
unicorn_running?.
|
90
|
+
unicorn_running?.should_not be_true
|
69
91
|
end
|
70
92
|
|
71
|
-
it 'quits
|
93
|
+
it 'quits on receiving INT signal' do
|
72
94
|
Process.kill 'INT', @wrangler_pid
|
73
95
|
sleep 1
|
74
96
|
wrangler_running?.should_not be_true
|
75
|
-
unicorn_running?.
|
97
|
+
unicorn_running?.should_not be_true
|
76
98
|
end
|
77
99
|
|
78
100
|
it 'quits if monitored unicorn process quits' do
|
@@ -81,7 +103,7 @@ describe Unicorn::Wrangler do
|
|
81
103
|
wrangler_running?.should_not be_true
|
82
104
|
end
|
83
105
|
|
84
|
-
it 'continues running
|
106
|
+
it 'continues running unless unicorn process quits' do
|
85
107
|
sleep 3
|
86
108
|
wrangler_running?.should be_true
|
87
109
|
end
|