async-container 0.20.1 → 0.22.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 +4 -4
- checksums.yaml.gz.sig +1 -3
- data/lib/async/container/forked.rb +22 -3
- data/lib/async/container/generic.rb +2 -2
- data/lib/async/container/threaded.rb +24 -2
- data/lib/async/container/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b99976b04ac8d7725349a23176ff2ca94643a4e95c96b6ab566a957be437d7
|
4
|
+
data.tar.gz: ec7aa60548299430c13b14d6abee5df28ec383b48dafb7e60432574bd07dd6fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b44d6496b6b9fa16bc288ecc66f0ba0645a0b3301d2a32bf53fbf27f993803cba38b6da9208baa3ef6c14fececb9da65cda6ab8d8ae403aa04c666c4077c978
|
7
|
+
data.tar.gz: 61d79bd5e62d8b406ffe88aae129918b5ab7c3de779847e8295e6dff867fdc58573c68e7df7bee585b9b204c6150dd98bc82fc424c8c6643df7eedd9dbd11f7c
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
���� ��,dz
|
3
|
-
-zE4�<��}s�J�7D]t�Đ$Z
|
1
|
+
F�^���W5�r)� �Qgm],�EEE��-����ՃBA0��*8_�r�ۡ��ȼ�d|)��ه� ��E w�>�(��/l2$P\O9�9���#�@R5��1%�0bHϧ
|
@@ -41,12 +41,24 @@ module Async
|
|
41
41
|
@name = nil
|
42
42
|
end
|
43
43
|
|
44
|
+
def as_json(...)
|
45
|
+
{
|
46
|
+
process_id: ::Process.pid,
|
47
|
+
name: @name,
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json(...)
|
52
|
+
as_json.to_json(...)
|
53
|
+
end
|
54
|
+
|
44
55
|
# Set the process title to the specified value.
|
45
56
|
# @parameter value [String] The name of the process.
|
46
57
|
def name= value
|
47
|
-
|
48
|
-
|
49
|
-
|
58
|
+
@name = value
|
59
|
+
|
60
|
+
# This sets the process title to an empty string if the name is nil:
|
61
|
+
::Process.setproctitle(@name.to_s)
|
50
62
|
end
|
51
63
|
|
52
64
|
# The name of the process.
|
@@ -180,6 +192,13 @@ module Async
|
|
180
192
|
end
|
181
193
|
end
|
182
194
|
|
195
|
+
# Send `SIGKILL` to the child process.
|
196
|
+
def kill!
|
197
|
+
unless @status
|
198
|
+
::Process.kill(:KILL, @pid)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
183
202
|
# Send `SIGHUP` to the child process.
|
184
203
|
def restart!
|
185
204
|
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
|
176
|
-
child.
|
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
|
@@ -50,12 +53,23 @@ module Async
|
|
50
53
|
end
|
51
54
|
|
52
55
|
def initialize(io)
|
53
|
-
@name = nil
|
54
56
|
@thread = ::Thread.current
|
55
57
|
|
56
58
|
super
|
57
59
|
end
|
58
60
|
|
61
|
+
def as_json(...)
|
62
|
+
{
|
63
|
+
process_id: ::Process.pid,
|
64
|
+
thread_id: @thread.object_id,
|
65
|
+
name: @thread.name,
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_json(...)
|
70
|
+
as_json.to_json(...)
|
71
|
+
end
|
72
|
+
|
59
73
|
# Set the name of the thread.
|
60
74
|
# @parameter value [String] The name to set.
|
61
75
|
def name= value
|
@@ -178,6 +192,14 @@ module Async
|
|
178
192
|
@thread.raise(Terminate)
|
179
193
|
end
|
180
194
|
|
195
|
+
# Invoke {Thread#kill} on the child thread.
|
196
|
+
def kill!
|
197
|
+
# Killing a thread does not raise an exception in the thread, so we need to handle the status here:
|
198
|
+
@status = Status.new(:killed)
|
199
|
+
|
200
|
+
@thread.kill
|
201
|
+
end
|
202
|
+
|
181
203
|
# Raise {Restart} in the child thread.
|
182
204
|
def restart!
|
183
205
|
@thread.raise(Restart)
|
@@ -230,7 +252,7 @@ module Async
|
|
230
252
|
Console.error(self) {error}
|
231
253
|
end
|
232
254
|
|
233
|
-
@status
|
255
|
+
@status ||= Status.new(error)
|
234
256
|
self.close_write
|
235
257
|
end
|
236
258
|
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.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2025-02-
|
43
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async
|
metadata.gz.sig
CHANGED
Binary file
|