sidekiq-pool 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 007c8607d7612d084d2836d9eba49ce492bd318e
4
- data.tar.gz: b38de4932f6f0e15212adad140d5121e736e8e2f
3
+ metadata.gz: 1e09b8656dabef56cc9db19da9ab961fae510cf9
4
+ data.tar.gz: 18eac57149dde145c504ae79efe5c02064e82499
5
5
  SHA512:
6
- metadata.gz: df48c578b96944b650df65db2fca3cf5ddc9d4ac59868769658e8c7bf20f36803c975b8a4dfc47406858ce72676a9dc84da0ee85dbdd652f994920e5d7d4eef8
7
- data.tar.gz: ae7248a39b67a5a6f4d6e09e4e209043b679f472ca00ff8cabe9aaff242f5c9dbae64c4b08c1e81ba5ce3b9e9a45538deb6369e332f71ab236ce792cc07ba27e
6
+ metadata.gz: a16ca326b2961c3e3e1db6f2835f00d65c0009b1778922e1b63b30c2e9921deed52ed8d44a83d3c7879fa44b41b80198c42db38a25860e7bfde239f60148246b
7
+ data.tar.gz: b075f9b7471a25a389fc8c2ec3adfc31ee57fd80ab9688ecd91cff99cdfce11ff634667482e6cb46a3016302a733085b8b5b58d0c224e95a641d2aa4add7787f
@@ -120,6 +120,10 @@ module Sidekiq
120
120
  @working_directory = arg
121
121
  end
122
122
 
123
+ o.on '--wait-until-child-loaded NUM', "Seconds to wait until forked child is busy" do |arg|
124
+ @wait_until_child_loaded = Integer(arg)
125
+ end
126
+
123
127
  o.on '-V', '--version', "Print version and exit" do |arg|
124
128
  puts "Sidekiq #{Sidekiq::VERSION}"
125
129
  die(0)
@@ -168,6 +172,15 @@ module Sidekiq
168
172
  options[:index] = @child_index++
169
173
  run_child
170
174
  end
175
+
176
+ wait_until_child_loaded ||= (@wait_until_child_loaded || 30)
177
+
178
+ until cmdline_busy?(pid)
179
+ break if (wait_until_child_loaded -= 1).zero?
180
+ logger.info "Waiting for child #{pid} to be busy break in #{wait_until_child_loaded}"
181
+ sleep 1
182
+ end
183
+
171
184
  @pool << { pid: pid, command: command }
172
185
  end
173
186
 
@@ -249,6 +262,13 @@ module Sidekiq
249
262
  false
250
263
  end
251
264
 
265
+ def cmdline_busy?(pid)
266
+ return unless alive?(pid)
267
+ cmdline = File.read("/proc/#{pid}/cmdline")
268
+ return if cmdline.empty?
269
+ !cmdline.scan(/busy\]/).empty?
270
+ end
271
+
252
272
  def stop_children(given_pool = @pool)
253
273
  @done = true
254
274
  logger.info 'Stopping children'
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Pool
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurynas Butkus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-07 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq