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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71bee49e7a7465805c10eee3e28597ed216727b6
4
- data.tar.gz: f19c67dbc73080d46de86a01a4142868569745ac
3
+ metadata.gz: cb60fbb2e08b91127b6efbfba149c02ef9e004ec
4
+ data.tar.gz: 59d7bd41e7344bd76e08694ec8058c7e14663d91
5
5
  SHA512:
6
- metadata.gz: 0aa20517db73067e8dbaaa3aadb35c355c3e9f8e5abe2ebdde07c64b6c87cf935893271a43ce5535475de6210bdee98c0b674ca42f8c6677b89948ca76985d35
7
- data.tar.gz: cf19b3a4c8d5b1861aee2d48356ab0bc1c4af868b3ea1231e2d1b3d3a74e668bcc6fd6e15c27690647b60e6d538d90a65ae8bd444c578da7c523e2cdc4f47457
6
+ metadata.gz: be04b0fce682d909b425db984789f224fb75b8ff8767268a60de2ac1c4775c39e37d5d36a749b058451a8de9dd4146c7ea4742ab56c0c972c375935b17962707
7
+ data.tar.gz: 61d6841bbfe9997c9a3578bd405a3e7e42033b8f724f05f4a5614d94d257329b8229568f5320b65fbccea128e70fc230625a18c313c3c12f94ecc793544d1412
@@ -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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module Unicorn
2
2
  class Wrangler
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn-wrangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ward