async-container 0.33.0 → 0.34.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 +0 -0
- data/lib/async/container/generic.rb +19 -8
- data/lib/async/container/version.rb +1 -1
- data/readme.md +4 -5
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: a0502d4a235533958f93fd6b4791479f056e42761394741af2427bfe027055bc
|
|
4
|
+
data.tar.gz: f4c07612adf5e21c1a7b5e86b0be8410e284f9606dad0daa5a4a3da9a94c7237
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a29ea78a23485e75e30a6e552bc8dcb18b3361844a8346e57eceec6d0db473747240f3c7818c1d6e6ceeb2cf59ac46d0115c11f13a1fded65dcfbfaef2d0d87
|
|
7
|
+
data.tar.gz: 26bbb632a633a15f18a32bd76ada51524e9671123e5d45f17721fb0a5eda22aa88d851f3b32c27272dfcf52279a2729fca909ba980839557ee50abab7426a3e7
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -47,7 +47,7 @@ module Async
|
|
|
47
47
|
# @parameter options [Hash] Options passed to the {Group} instance.
|
|
48
48
|
def initialize(policy: Policy::DEFAULT, **options)
|
|
49
49
|
@group = Group.new(**options)
|
|
50
|
-
@
|
|
50
|
+
@stopping = false
|
|
51
51
|
|
|
52
52
|
@state = {}
|
|
53
53
|
|
|
@@ -97,6 +97,12 @@ module Async
|
|
|
97
97
|
@group.running?
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
+
# Whether the container is currently stopping.
|
|
101
|
+
# @returns [Boolean]
|
|
102
|
+
def stopping?
|
|
103
|
+
@stopping
|
|
104
|
+
end
|
|
105
|
+
|
|
100
106
|
# Sleep until some state change occurs or the specified duration elapses.
|
|
101
107
|
#
|
|
102
108
|
# @parameter duration [Numeric] the maximum amount of time to sleep for.
|
|
@@ -147,8 +153,13 @@ module Async
|
|
|
147
153
|
# Stop the children instances.
|
|
148
154
|
# @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
|
|
149
155
|
def stop(timeout = true)
|
|
156
|
+
if @stopping
|
|
157
|
+
Console.warn(self, "Container is already stopping!")
|
|
158
|
+
return
|
|
159
|
+
end
|
|
160
|
+
|
|
150
161
|
Console.info(self, "Stopping container...", timeout: timeout)
|
|
151
|
-
@
|
|
162
|
+
@stopping = true
|
|
152
163
|
@group.stop(timeout)
|
|
153
164
|
|
|
154
165
|
if @group.running?
|
|
@@ -160,7 +171,7 @@ module Async
|
|
|
160
171
|
Console.error(self, "Error while stopping container!", exception: error)
|
|
161
172
|
raise
|
|
162
173
|
ensure
|
|
163
|
-
@
|
|
174
|
+
@stopping = false
|
|
164
175
|
end
|
|
165
176
|
|
|
166
177
|
protected def health_check_failed(child, age_clock, health_check_timeout)
|
|
@@ -206,7 +217,7 @@ module Async
|
|
|
206
217
|
@statistics.spawn!
|
|
207
218
|
|
|
208
219
|
fiber do
|
|
209
|
-
|
|
220
|
+
until @stopping
|
|
210
221
|
Console.debug(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
|
|
211
222
|
|
|
212
223
|
child = self.start(name, &block)
|
|
@@ -257,16 +268,16 @@ module Async
|
|
|
257
268
|
end
|
|
258
269
|
end
|
|
259
270
|
rescue => error
|
|
260
|
-
Console.error(self, "Error during child process management!", exception: error,
|
|
271
|
+
Console.error(self, "Error during child process management!", exception: error, stopping: @stopping)
|
|
261
272
|
ensure
|
|
262
273
|
delete(key, child)
|
|
263
274
|
end
|
|
264
275
|
|
|
265
276
|
if status&.success?
|
|
266
|
-
Console.debug(self, "Child exited successfully.", status: status,
|
|
277
|
+
Console.debug(self, "Child exited successfully.", status: status, stopping: @stopping)
|
|
267
278
|
else
|
|
268
279
|
@statistics.failure!
|
|
269
|
-
Console.error(self, "Child exited with error!", status: status,
|
|
280
|
+
Console.error(self, "Child exited with error!", status: status, stopping: @stopping)
|
|
270
281
|
end
|
|
271
282
|
|
|
272
283
|
# Notify policy of exit (after statistics are updated):
|
|
@@ -276,7 +287,7 @@ module Async
|
|
|
276
287
|
Console.error(self, "Policy error in child_exit!", exception: error)
|
|
277
288
|
end
|
|
278
289
|
|
|
279
|
-
if restart &&
|
|
290
|
+
if restart && !@stopping
|
|
280
291
|
@statistics.restart!
|
|
281
292
|
else
|
|
282
293
|
break
|
data/readme.md
CHANGED
|
@@ -28,6 +28,10 @@ Please see the [project documentation](https://socketry.github.io/async-containe
|
|
|
28
28
|
|
|
29
29
|
Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
|
|
30
30
|
|
|
31
|
+
### v0.34.0
|
|
32
|
+
|
|
33
|
+
- Add `Async::Container::Generic#stopping?` so that policies can more accurately track the state of the container.
|
|
34
|
+
|
|
31
35
|
### v0.33.0
|
|
32
36
|
|
|
33
37
|
- Add `Policy#make_statistics` to allow policies to customize statistics initialization.
|
|
@@ -69,11 +73,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
|
|
|
69
73
|
|
|
70
74
|
- Fix race condition where `wait_for` could modify `@running` while it was being iterated over (`each_value`) during health checks.
|
|
71
75
|
|
|
72
|
-
### v0.27.3
|
|
73
|
-
|
|
74
|
-
- Add log for starting child, including container statistics.
|
|
75
|
-
- Don't try to (log) "terminate 0 child processes" if there are none.
|
|
76
|
-
|
|
77
76
|
## Contributing
|
|
78
77
|
|
|
79
78
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|