sidekiq-pool 1.8.1 → 1.9.2

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
  SHA256:
3
- metadata.gz: ca3fa913c595d916c0df9e2897c6047fae80eef1f78e3a7e53779874c9e3ade9
4
- data.tar.gz: 20d365396e1a193714f91a8c80dc625e29e1d309acd66ce9f6b53de38e603619
3
+ metadata.gz: 6ec19ae3f1256d1c291c33af8c7e95ab8aa2139b519035947ce7206b5e1af32c
4
+ data.tar.gz: 8a7f862dcb0729c9ea68c87a33307a167e62475915e5ffc8f688f367258dcd9b
5
5
  SHA512:
6
- metadata.gz: 8138fb77f6ca5e6601955f513ad5a0d0ed2953f87f1e1179aa575fc7e8d6d43fb5b995497d34babf70e6c3be168cef5c59cc3c289abeb55a4cd0ae1676790c41
7
- data.tar.gz: 054f960402c6888ede263ab667389fc3bbaf0d1352b3acf7f040b0d6bb57f18f251de2d4ac99207fc48bdad42a45ac204f12fb4dc906457014f4527723ffb91b
6
+ metadata.gz: ac9432289be3890128ed433dbff50f3df482418d966e8af02ad99045554745f4b71504b03985772e2ea8afbb283b193fd9553c2c8056a8aa1fff44a2ff2586cd
7
+ data.tar.gz: cf1ffe878314497d4559561dba70bfe282e128b78a5ef7aa4ae61e2a101cba693b9041fa6429a929845ca35d8abdcbb20b6c18f3cc59ade5af61af77015299dc
@@ -11,7 +11,6 @@ module Sidekiq
11
11
  }
12
12
 
13
13
  def initialize
14
- @child_index = 0
15
14
  @pool = []
16
15
  @done = false
17
16
  @system_booted = false
@@ -20,8 +19,13 @@ module Sidekiq
20
19
 
21
20
  alias_method :run_child, :run
22
21
 
22
+ def write_pid
23
+ super if @master_pid == ::Process.pid
24
+ end
25
+
23
26
  def run
24
27
  @master_pid = $$
28
+ write_pid
25
29
 
26
30
  trap_signals
27
31
  update_process_name
@@ -69,10 +73,12 @@ module Sidekiq
69
73
  boot_system
70
74
 
71
75
  @types = @settings[:workers]
76
+ index = -1
72
77
  @types.each do |type|
73
78
  type[:amount].times do
79
+ index += 1
74
80
  sleep @fork_wait || DEFAULT_FORK_WAIT
75
- fork_child(type[:command])
81
+ fork_child(type[:command], index)
76
82
  end
77
83
  end
78
84
  drop_reload_marker
@@ -189,7 +195,7 @@ module Sidekiq
189
195
  end
190
196
  end
191
197
 
192
- def fork_child(command, wait_for_busy = true)
198
+ def fork_child(command, index, wait_for_busy = true)
193
199
  logger.info "Adding child with args: (#{command}) in #{working_directory}, waiting for busy: #{wait_for_busy}"
194
200
  if working_directory && !Dir.exist?(working_directory)
195
201
  logger.info "Working directory: #{working_directory} does not exist unable to fork"
@@ -202,14 +208,14 @@ module Sidekiq
202
208
  options.merge!(opts)
203
209
 
204
210
  @self_write.close
205
- $0 = 'sidekiq starting'
206
- @child_index += 1
207
- options[:index] = @child_index
211
+ $0 = "sidekiq #{Sidekiq::VERSION} worker #{index} starting"
212
+ options[:index] = index
208
213
 
209
214
  # reset child identity
210
215
  @@process_nonce = nil
211
216
  @@identity = nil
212
217
  options[:identity] = identity
218
+ options[:tag] = "worker #{index}"
213
219
 
214
220
  run_after_fork_hooks
215
221
  run_child
@@ -223,7 +229,7 @@ module Sidekiq
223
229
  sleep 1
224
230
  end if wait_for_busy
225
231
 
226
- @pool << { pid: pid, command: command }
232
+ @pool << { pid: pid, index: index, command: command }
227
233
  end
228
234
 
229
235
  def wait_for_signals
@@ -309,9 +315,9 @@ module Sidekiq
309
315
  end
310
316
 
311
317
  def handle_dead_child(child)
312
- logger.info "Child #{child[:pid]} died"
318
+ logger.info "Child #{child[:pid]} (worker #{child[:index]}) died"
313
319
  @pool.delete(child)
314
- fork_child(child[:command], false)
320
+ fork_child(child[:command], child[:index], false)
315
321
  end
316
322
 
317
323
  def alive?(pid)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Pool
3
- VERSION = '1.8.1'
3
+ VERSION = '1.9.2'
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.8.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinted
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq