unicorn-wrangler 0.0.3 → 0.0.4
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/bin/unicorn-wrangler +4 -0
- data/lib/unicorn/wrangler.rb +2 -1
- data/lib/unicorn/wrangler/version.rb +1 -1
- data/spec/lib/unicorn/wrangler_spec.rb +29 -2
- 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: cb60fbb2e08b91127b6efbfba149c02ef9e004ec
|
4
|
+
data.tar.gz: 59d7bd41e7344bd76e08694ec8058c7e14663d91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be04b0fce682d909b425db984789f224fb75b8ff8767268a60de2ac1c4775c39e37d5d36a749b058451a8de9dd4146c7ea4742ab56c0c972c375935b17962707
|
7
|
+
data.tar.gz: 61d6841bbfe9997c9a3578bd405a3e7e42033b8f724f05f4a5614d94d257329b8229568f5320b65fbccea128e70fc230625a18c313c3c12f94ecc793544d1412
|
data/bin/unicorn-wrangler
CHANGED
@@ -16,6 +16,10 @@ OptionParser.new do |opts|
|
|
16
16
|
opts.on("-s", "--startup-time STARTUP", "Time to wait for server to start") do |time|
|
17
17
|
options[:startup] = time.to_i
|
18
18
|
end
|
19
|
+
|
20
|
+
opts.on("-k", "--keep-unicorn-running", "Keep unicorn running on exit") do
|
21
|
+
options[:keep_unicorn] = true
|
22
|
+
end
|
19
23
|
end.parse!(ARGV[0...command_index])
|
20
24
|
|
21
25
|
launcher = Unicorn::Wrangler.new command, options
|
data/lib/unicorn/wrangler.rb
CHANGED
@@ -8,12 +8,13 @@ module Unicorn
|
|
8
8
|
@command = command
|
9
9
|
@pidfile = File.expand_path(options[:pidfile] || 'unicorn.pid')
|
10
10
|
@startup_period = options[:startup] || 60
|
11
|
+
@keep_unicorn = options[:keep_unicorn]
|
11
12
|
end
|
12
13
|
|
13
14
|
def start
|
14
15
|
trap_signals(:HUP) { restart_unicorn }
|
15
16
|
trap_signals(:QUIT, :INT, :TERM) do |signal|
|
16
|
-
Process.kill signal, unicorn_pid if unicorn_running?
|
17
|
+
Process.kill signal, unicorn_pid if unicorn_running? && !@keep_unicorn
|
17
18
|
exit
|
18
19
|
end
|
19
20
|
|
@@ -18,8 +18,8 @@ describe Unicorn::Wrangler do
|
|
18
18
|
sleep 1
|
19
19
|
end
|
20
20
|
|
21
|
-
def start_wrangler
|
22
|
-
@wrangler_pid = Process.spawn "#{wrangler_path} --startup-time 1 -p spec/support/unicorn.pid -- #{unicorn_cmd}"
|
21
|
+
def start_wrangler(extra = '')
|
22
|
+
@wrangler_pid = Process.spawn "#{wrangler_path} --startup-time 1 #{extra} -p spec/support/unicorn.pid -- #{unicorn_cmd}"
|
23
23
|
sleep 1
|
24
24
|
end
|
25
25
|
|
@@ -146,6 +146,33 @@ describe Unicorn::Wrangler do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
context 'when passed the --keep-unicorn flag' do
|
150
|
+
before :each do
|
151
|
+
start_wrangler '--keep-unicorn'
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'keeps unicorn running after receiving QUIT signal' do
|
155
|
+
Process.kill 'QUIT', @wrangler_pid
|
156
|
+
sleep 1
|
157
|
+
wrangler_running?.should_not be_true
|
158
|
+
unicorn_running?.should be_true
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'keeps unicorn running after receiving TERM signal' do
|
162
|
+
Process.kill 'TERM', @wrangler_pid
|
163
|
+
sleep 1
|
164
|
+
wrangler_running?.should_not be_true
|
165
|
+
unicorn_running?.should be_true
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'keeps unicorn running after receiving INT signal' do
|
169
|
+
Process.kill 'INT', @wrangler_pid
|
170
|
+
sleep 1
|
171
|
+
wrangler_running?.should_not be_true
|
172
|
+
unicorn_running?.should be_true
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
149
176
|
before :each do
|
150
177
|
cleanup_processes
|
151
178
|
end
|