async-container 0.20.1 → 0.21.0

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: 2435dd48259ab4b6bbad01780c21dc91bdf2946485f1dd682c8388b9ee68410d
4
- data.tar.gz: c8e3564e5c889f469658eb044444bc6884575090ed38e73f07bcffdfe893f823
3
+ metadata.gz: 6dd27e02912c5f1258419c9821da1bd97d58f4fd68b4a58512b3ebd5291c5b6b
4
+ data.tar.gz: 36fc9d2d0ce94a0e2591beac3384d2fba288094a93c1ada7a9000841c1e78a59
5
5
  SHA512:
6
- metadata.gz: fa56a0207d1bab96685c25ca8f3617a5e5aefeb673998d836780baf75e1ff9ee9618ac4e506f893de206f425277a7abb0dc12f748850d59e037f5f155763b9d9
7
- data.tar.gz: 1198eaa52f0ea7dfe3b411c1e6cf6866f720f9aa4b5b1913fee2fbb535144115b4e2e3e21e313fa01faa64e724e7e786e32732c0889d2c8601c8ccce72dfe967
6
+ metadata.gz: 162f3604bbaa973b486fc271ccf61106008a5d2259f114134535188349267ee3dfb81cbe857ce7edc49dd2037b5d1f5581dd531955ddbfba264a113638e300cd
7
+ data.tar.gz: b1ba5f8e3b96976a97b6f81e20a62efbcbde89e4e2f0be43c754954a44924e2553c447cf275121ce74894d0044e7677a144c7f43df5f77d7a55b263f6442eb96
checksums.yaml.gz.sig CHANGED
Binary file
@@ -180,6 +180,13 @@ module Async
180
180
  end
181
181
  end
182
182
 
183
+ # Send `SIGKILL` to the child process.
184
+ def kill!
185
+ unless @status
186
+ ::Process.kill(:KILL, @pid)
187
+ end
188
+ end
189
+
183
190
  # Send `SIGHUP` to the child process.
184
191
  def restart!
185
192
  unless @status
@@ -172,8 +172,8 @@ module Async
172
172
  when :health_check!
173
173
  if health_check_timeout&.<(age_clock.total)
174
174
  Console.warn(self, "Child failed health check!", child: child, age: age_clock.total, health_check_timeout: health_check_timeout)
175
- # If the child has failed the health check, we assume the worst and terminate it (SIGTERM).
176
- child.terminate!
175
+ # If the child has failed the health check, we assume the worst and kill it immediately:
176
+ child.kill!
177
177
  end
178
178
  else
179
179
  state.update(message)
@@ -11,6 +11,9 @@ module Async
11
11
  module Container
12
12
  # A multi-thread container which uses {Thread.fork}.
13
13
  class Threaded < Generic
14
+ class Kill < Exception
15
+ end
16
+
14
17
  # Indicates that this is not a multi-process container.
15
18
  def self.multiprocess?
16
19
  false
@@ -178,6 +181,14 @@ module Async
178
181
  @thread.raise(Terminate)
179
182
  end
180
183
 
184
+ # Invoke {Thread#kill} on the child thread.
185
+ def kill!
186
+ # Killing a thread does not raise an exception in the thread, so we need to handle the status here:
187
+ @status = Status.new(:killed)
188
+
189
+ @thread.kill
190
+ end
191
+
181
192
  # Raise {Restart} in the child thread.
182
193
  def restart!
183
194
  @thread.raise(Restart)
@@ -230,7 +241,7 @@ module Async
230
241
  Console.error(self) {error}
231
242
  end
232
243
 
233
- @status = Status.new(error)
244
+ @status ||= Status.new(error)
234
245
  self.close_write
235
246
  end
236
247
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.20.1"
8
+ VERSION = "0.21.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -22,6 +22,10 @@ Please see the [project documentation](https://socketry.github.io/async-containe
22
22
 
23
23
  Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
24
24
 
25
+ ### v0.21.0
26
+
27
+ - Use `SIGKILL`/`Thread#kill` when the health check fails. In some cases, `SIGTERM` may not be sufficient to terminate a process because the signal can be ignored or the process may be in an uninterruptible state.
28
+
25
29
  ### v0.20.1
26
30
 
27
31
  - Fix compatibility between <code class="language-ruby">Async::Container::Hybrid</code> and the health check.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.21.0
4
+
5
+ - Use `SIGKILL`/`Thread#kill` when the health check fails. In some cases, `SIGTERM` may not be sufficient to terminate a process because the signal can be ignored or the process may be in an uninterruptible state.
6
+
3
7
  ## v0.20.1
4
8
 
5
9
  - Fix compatibility between {ruby Async::Container::Hybrid} and the health check.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file