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 +4 -4
- data/README.md +1 -1
- data/lib/sidekiq/pool/cli.rb +8 -4
- data/lib/sidekiq/pool/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4da8dc5a63c3064f8f47611eda064ec761d1a2a
|
4
|
+
data.tar.gz: 404bc17015af307993c2ae053d2c31c384730a6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e79c107dc03d30521a5a1f9ebe6a0a681bac20d0e03917690c866771d5ef6dc3a63300d94a3734c156471339e5a7eb30611a22be3e1220325451b5ddaba6b6a
|
7
|
+
data.tar.gz: 74ad243c626ed4e11cc006dd29e2a5bedf77a2ef50ad8c726d2434ecb0ae6f168a5347db3cbbb154afcf968e3a728067382be1c1ce456ad71ea802dc3ce78e81
|
data/README.md
CHANGED
data/lib/sidekiq/pool/cli.rb
CHANGED
@@ -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
|
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 '
|
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
|
-
|
213
|
+
$$ != @master_pid
|
210
214
|
end
|
211
215
|
end
|
212
216
|
end
|
data/lib/sidekiq/pool/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|