sidekiq-pool 0.1.2 → 0.1.3

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: b18df834e83b27a7507863976c2af09c93fea20d
4
- data.tar.gz: 197cf40e14dda748bf363f33324fc753878de775
3
+ metadata.gz: b4da8dc5a63c3064f8f47611eda064ec761d1a2a
4
+ data.tar.gz: 404bc17015af307993c2ae053d2c31c384730a6a
5
5
  SHA512:
6
- metadata.gz: 7fa18f3e36552979d1d0ae685323ef145fb3cdf5e8ce2eb3f8ba9825c8001829bf46b57481d9daffba77cbcb65262da67818416ed68352fde1e2436fe272b5bf
7
- data.tar.gz: c4ccef02df6cfa61e0ef0263769e987953107b3949faaad1d8a0ee22351fdca799b0cb439b41c1517b63580f8586d6bc3fb17bfb1b496e63db73b3db2ec9c89a
6
+ metadata.gz: 9e79c107dc03d30521a5a1f9ebe6a0a681bac20d0e03917690c866771d5ef6dc3a63300d94a3734c156471339e5a7eb30611a22be3e1220325451b5ddaba6b6a
7
+ data.tar.gz: 74ad243c626ed4e11cc006dd29e2a5bedf77a2ef50ad8c726d2434ecb0ae6f168a5347db3cbbb154afcf968e3a728067382be1c1ce456ad71ea802dc3ce78e81
data/README.md CHANGED
@@ -28,7 +28,7 @@ Signals `USR1`, `USR2` are forwarded to the children.
28
28
 
29
29
  $ kill -TTIN masterpid
30
30
 
31
- `TTOU` kills one child
31
+ `TTOU` stops one child
32
32
 
33
33
  $ kill -TTOU masterpid
34
34
 
@@ -4,7 +4,6 @@ module Sidekiq
4
4
  module Pool
5
5
  class CLI < Sidekiq::CLI
6
6
  def initialize
7
- @master_pid = ::Process.pid
8
7
  @child_index = 0
9
8
  @pool = []
10
9
  super
@@ -14,6 +13,9 @@ module Sidekiq
14
13
 
15
14
  def run
16
15
  logger.info "Starting pool with #{@pool_size} instances"
16
+
17
+ @master_pid = $$
18
+
17
19
  trap_signals
18
20
 
19
21
  @pool_size.times { fork_child }
@@ -104,7 +106,7 @@ module Sidekiq
104
106
  def trap_signals
105
107
  @self_read, @self_write = IO.pipe
106
108
 
107
- %w(INT TERM USR1 USR2 TTIN TTOU CLD).each do |sig|
109
+ %w(INT TERM USR1 USR2 TTIN TTOU CHLD).each do |sig|
108
110
  begin
109
111
  trap sig do
110
112
  @self_write.puts(sig) unless fork?
@@ -140,7 +142,7 @@ module Sidekiq
140
142
  add_child
141
143
  when 'TTOU'
142
144
  remove_child
143
- when 'CLD'
145
+ when 'CHLD'
144
146
  check_pool
145
147
  when 'USR1', 'USR2'
146
148
  logger.info "Sending #{sig} signal to the pool"
@@ -176,6 +178,7 @@ module Sidekiq
176
178
  end
177
179
 
178
180
  def check_pool
181
+ ::Process.waitpid2(-1, ::Process::WNOHANG)
179
182
  @pool.each do |pid|
180
183
  next if alive?(pid)
181
184
  handle_dead_child(pid)
@@ -201,12 +204,13 @@ module Sidekiq
201
204
  loop do
202
205
  signal_to_pool('TERM')
203
206
  sleep(1)
207
+ ::Process.waitpid2(-1, ::Process::WNOHANG)
204
208
  break if @pool.none? { |pid| alive?(pid) }
205
209
  end
206
210
  end
207
211
 
208
212
  def fork?
209
- ::Process.pid != @master_pid
213
+ $$ != @master_pid
210
214
  end
211
215
  end
212
216
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Pool
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
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: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurynas Butkus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq