sidekiq-process_manager 1.1.0 → 1.1.1

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
  SHA256:
3
- metadata.gz: d03e818fac3487ed18d2763f536b2e97fa526b8d7dd066b1a066407727ff0dba
4
- data.tar.gz: 1e3e1837c3367a22ced37e111ad6e7d1e9988bcdd7baaf1d07b0b3083857650e
3
+ metadata.gz: 51d57e09aba69d64225948647f2f95625c668b44eb16e514b5ab4daf8e064e3c
4
+ data.tar.gz: 73d49c20ce5bf06a8d84a168d8e1afa2b04883ea1656d3d4e0ac96b66855140c
5
5
  SHA512:
6
- metadata.gz: feae2e03df3bc77c6590a1da6bcb5079761184a6e5d37f05c81451b7f52783c8b496dbbdfa71b793a8adfe7eaf8bde293e185ec1ecc1b0a90a802cab772a30dc
7
- data.tar.gz: 988f0f484e747142c8b725e80717bc0edefee68d9600595352f27a2c343535bc2c6e56ecde5c10dccf56c775b1210f9e50f3a542ed2095fd2e0041fedbfcff93
6
+ metadata.gz: 2f35e8a6ccbbcbaa15fbbbd62658bd79e4337e675a0c4a776e8dc2c6457bb957ed5ba9880336532a68f54e5ea13890917d758d5f84a2395130c0c52a5166a7cc
7
+ data.tar.gz: dd4fa55ec09584a890e5125d93a64d15924b138583d23e91331a1818bec0c58dfa0cdd81ab58bfab37951a645ed41e149fa04996ec89d11c85c0362204c21be4
data/CHANGELOG.md CHANGED
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [1.1.0] - Unreleased
7
+ ## 1.1.1
8
+
9
+ ### Added
10
+ - Guards to ensure signal processing thread doesn't die.
11
+
12
+ ## 1.1.0
8
13
 
9
14
  ### Added
10
15
  - Sidekiq 7 support.
@@ -15,17 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
20
  - Sidekiq < 5.0 support.
16
21
  - Ruby < 2.5 support.
17
22
 
18
- ## [1.0.4] - 2021-05-20
23
+ ## 1.0.4
19
24
 
20
25
  ### Fixed
21
26
  - Set $0 to "sidekiq" in preforked process so instrumentation libraries detecting sidekiq server from the command line will work.
22
27
 
23
- ## [1.0.3] - 2021-05-19
28
+ ## 1.0.3
24
29
 
25
30
  ### Fixed
26
31
  - Restore bin dir to gem distribution.
27
32
 
28
- ## [1.0.2] - 2021-05-19
33
+ ## 1.0.2
29
34
 
30
35
  ### Added
31
36
  - Support for sidekiq >= 6.1.
@@ -34,12 +39,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
34
39
  ### Changed
35
40
  - Minimum Ruby version 2.3.
36
41
 
37
- ## [1.0.1] - 2020-02-20
42
+ ## 1.0.1
38
43
 
39
44
  ### Changed
40
45
  - Remove auto require of `sidekiq/cli` so `require: false` does not need to be specified in a Gemfile.
41
46
 
42
- ## [1.0.0] - 2019-11-27
47
+ ## 1.0.0
43
48
 
44
49
  ### Added
45
50
  - Initial release.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -64,6 +64,19 @@ module Sidekiq
64
64
 
65
65
  @signal_pipe_read, @signal_pipe_write = IO.pipe
66
66
 
67
+ @signal_thread = Thread.new do
68
+ Thread.current.name = "signal-handler"
69
+
70
+ while @signal_pipe_read.wait_readable
71
+ begin
72
+ signal = @signal_pipe_read.gets.strip
73
+ send_signal_to_children(signal.to_sym)
74
+ rescue => e
75
+ log_error("Error handling signal #{signal}: #{e.message}")
76
+ end
77
+ end
78
+ end
79
+
67
80
  # Trap signals that will be forwarded to child processes
68
81
  [:INT, :TERM, :USR1, :USR2, :TSTP, :TTIN].each do |signal|
69
82
  ::Signal.trap(signal) do
@@ -73,15 +86,6 @@ module Sidekiq
73
86
  end
74
87
  end
75
88
 
76
- @signal_thread = Thread.new do
77
- Thread.current.name = "signal-handler"
78
-
79
- while @signal_pipe_read.wait_readable
80
- signal = @signal_pipe_read.gets.strip
81
- send_signal_to_children(signal.to_sym)
82
- end
83
- end
84
-
85
89
  # Ensure that child processes receive the term signal when the master process exits.
86
90
  at_exit do
87
91
  if ::Process.pid == master_pid && @process_count > 0
@@ -143,15 +147,6 @@ module Sidekiq
143
147
  @started
144
148
  end
145
149
 
146
- # Kill a child process by sending the TERM signal to it.
147
- #
148
- # @param pid [Integer] The pid of the child process to kill.
149
- # @return [void]
150
- # @api private
151
- def kill(pid)
152
- ::Process.kill(:TERM, pid)
153
- end
154
-
155
150
  private
156
151
 
157
152
  def log_info(message)
@@ -265,7 +260,11 @@ module Sidekiq
265
260
  memory = GetProcessMem.new(pid)
266
261
  if memory.bytes > @max_memory
267
262
  log_warning("Kill bloated sidekiq process #{pid}: #{memory.mb.round}mb used")
268
- kill(pid)
263
+ begin
264
+ ::Process.kill(:TERM, pid)
265
+ rescue Errno::ESRCH
266
+ # The process is already dead
267
+ end
269
268
  break
270
269
  end
271
270
  rescue => e
@@ -292,7 +291,11 @@ module Sidekiq
292
291
  end
293
292
 
294
293
  pids.each do |pid|
295
- ::Process.kill(:INT, pid) if process_alive?(pid)
294
+ begin
295
+ ::Process.kill(:INT, pid) if process_alive?(pid)
296
+ rescue
297
+ # Ignore errors so we can continue to kill other processes.
298
+ end
296
299
  end
297
300
  end
298
301
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-process_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand