async-container 0.27.1 → 0.27.3
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/controller.rb +10 -11
- data/lib/async/container/forked.rb +0 -1
- data/lib/async/container/generic.rb +19 -5
- data/lib/async/container/group.rb +3 -3
- data/lib/async/container/statistics.rb +18 -0
- data/lib/async/container/version.rb +1 -1
- data/readme.md +9 -6
- data/releases.md +9 -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: a8429de04372759748416b6b4e52a99ea6f7e89702f46d988d25301f958ca877
|
4
|
+
data.tar.gz: c24245f1fe1228f61418717be4f3096503682bfe4e3b12b2bfb1272a89e0f16e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df4d5a6c2a9c24fa7a054deda82445653690b7e51bb6828921b703ae77debb20eec636d2db962990501263a33482695e9d05eeb9170c1d72243bfd5f60d5d2a1
|
7
|
+
data.tar.gz: 972c007d20d6f023c8fea9f162009a37af2449947ff502e2e9af7041c025991726aafc0f2a19bef10be02d1c9612a99e1bf04d9612752cdfbf8d839de3ca9d37
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -91,11 +91,11 @@ module Async
|
|
91
91
|
# Start the container unless it's already running.
|
92
92
|
def start
|
93
93
|
unless @container
|
94
|
-
Console.info(self
|
94
|
+
Console.info(self, "Controller starting...")
|
95
95
|
self.restart
|
96
96
|
end
|
97
97
|
|
98
|
-
Console.info(self
|
98
|
+
Console.info(self, "Controller started...")
|
99
99
|
end
|
100
100
|
|
101
101
|
# Stop the container if it's running.
|
@@ -111,9 +111,9 @@ module Async
|
|
111
111
|
if @container
|
112
112
|
@notify&.restarting!
|
113
113
|
|
114
|
-
Console.
|
114
|
+
Console.info(self, "Restarting container...")
|
115
115
|
else
|
116
|
-
Console.
|
116
|
+
Console.info(self, "Starting container...")
|
117
117
|
end
|
118
118
|
|
119
119
|
container = self.create_container
|
@@ -127,13 +127,14 @@ module Async
|
|
127
127
|
end
|
128
128
|
|
129
129
|
# Wait for all child processes to enter the ready state.
|
130
|
-
Console.
|
130
|
+
Console.info(self, "Waiting for startup...")
|
131
131
|
container.wait_until_ready
|
132
|
-
Console.
|
132
|
+
Console.info(self, "Finished startup.")
|
133
133
|
|
134
134
|
if container.failed?
|
135
135
|
@notify&.error!("Container failed to start!")
|
136
136
|
|
137
|
+
Console.info(self, "Stopping failed container...")
|
137
138
|
container.stop(false)
|
138
139
|
|
139
140
|
raise SetupError, container
|
@@ -145,7 +146,7 @@ module Async
|
|
145
146
|
container = nil
|
146
147
|
|
147
148
|
if old_container
|
148
|
-
Console.
|
149
|
+
Console.info(self, "Stopping old container...")
|
149
150
|
old_container&.stop(@graceful_stop)
|
150
151
|
end
|
151
152
|
|
@@ -168,11 +169,9 @@ module Async
|
|
168
169
|
end
|
169
170
|
|
170
171
|
# Wait for all child processes to enter the ready state.
|
171
|
-
Console.
|
172
|
-
|
172
|
+
Console.info(self, "Waiting for startup...")
|
173
173
|
@container.wait_until_ready
|
174
|
-
|
175
|
-
Console.debug(self, "Finished startup.")
|
174
|
+
Console.info(self, "Finished startup.")
|
176
175
|
|
177
176
|
if @container.failed?
|
178
177
|
@notify.error!("Container failed to reload!")
|
@@ -139,12 +139,18 @@ module Async
|
|
139
139
|
# Stop the children instances.
|
140
140
|
# @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
|
141
141
|
def stop(timeout = true)
|
142
|
+
Console.info(self, "Stopping container...", timeout: timeout, caller: caller_locations)
|
142
143
|
@running = false
|
143
144
|
@group.stop(timeout)
|
144
145
|
|
145
146
|
if @group.running?
|
146
|
-
Console.warn(self
|
147
|
+
Console.warn(self, "Group is still running after stopping it!")
|
148
|
+
else
|
149
|
+
Console.info(self, "Group has stopped.")
|
147
150
|
end
|
151
|
+
rescue => error
|
152
|
+
Console.error(self, "Error while stopping container!", exception: error)
|
153
|
+
raise
|
148
154
|
ensure
|
149
155
|
@running = true
|
150
156
|
end
|
@@ -165,7 +171,7 @@ module Async
|
|
165
171
|
name ||= UNNAMED
|
166
172
|
|
167
173
|
if mark?(key)
|
168
|
-
Console.debug(self
|
174
|
+
Console.debug(self, "Reusing existing child.", child: {key: key, name: name})
|
169
175
|
return false
|
170
176
|
end
|
171
177
|
|
@@ -173,10 +179,13 @@ module Async
|
|
173
179
|
|
174
180
|
fiber do
|
175
181
|
while @running
|
176
|
-
child
|
182
|
+
Console.info(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
|
177
183
|
|
184
|
+
child = self.start(name, &block)
|
178
185
|
state = insert(key, child)
|
179
186
|
|
187
|
+
Console.info(self, "Started child.", child: child, spawn: {key: key, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
|
188
|
+
|
180
189
|
# If a health check is specified, we will monitor the child process and terminate it if it does not update its state within the specified time.
|
181
190
|
if health_check_timeout
|
182
191
|
age_clock = state[:age] = Clock.start
|
@@ -199,10 +208,10 @@ module Async
|
|
199
208
|
end
|
200
209
|
|
201
210
|
if status.success?
|
202
|
-
Console.
|
211
|
+
Console.info(self, "Child exited successfully.", status: status, running: @running)
|
203
212
|
else
|
204
213
|
@statistics.failure!
|
205
|
-
Console.error(self, status: status)
|
214
|
+
Console.error(self, "Child exited with error!", status: status, running: @running)
|
206
215
|
end
|
207
216
|
|
208
217
|
if restart
|
@@ -211,6 +220,11 @@ module Async
|
|
211
220
|
break
|
212
221
|
end
|
213
222
|
end
|
223
|
+
rescue => error
|
224
|
+
Console.error(self, "Failure during child process management!", exception: error, running: @running)
|
225
|
+
raise
|
226
|
+
ensure
|
227
|
+
Console.info(self, "Child process management loop exited.", running: @running)
|
214
228
|
end.resume
|
215
229
|
|
216
230
|
return true
|
@@ -183,7 +183,7 @@ module Async
|
|
183
183
|
self.wait_for_exit(clock, interrupt_timeout)
|
184
184
|
end
|
185
185
|
|
186
|
-
if terminate_timeout
|
186
|
+
if terminate_timeout and self.any?
|
187
187
|
clock = Async::Clock.start
|
188
188
|
|
189
189
|
# If the children are still running, terminate them:
|
@@ -231,8 +231,8 @@ module Async
|
|
231
231
|
protected
|
232
232
|
|
233
233
|
def wait_for_children(duration = nil)
|
234
|
-
# This log is a
|
235
|
-
|
234
|
+
# This log is a bit noisy and doesn't really provide a lot of useful information:
|
235
|
+
Console.debug(self, "Waiting for children...", duration: duration, running: @running)
|
236
236
|
|
237
237
|
unless @running.empty?
|
238
238
|
# Maybe consider using a proper event loop here:
|
@@ -56,6 +56,24 @@ module Async
|
|
56
56
|
@restarts += other.restarts
|
57
57
|
@failures += other.failures
|
58
58
|
end
|
59
|
+
|
60
|
+
# Generate a hash representation of the statistics.
|
61
|
+
#
|
62
|
+
# @returns [Hash] The statistics as a hash.
|
63
|
+
def as_json(...)
|
64
|
+
{
|
65
|
+
spawns: @spawns,
|
66
|
+
restarts: @restarts,
|
67
|
+
failures: @failures,
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Generate a JSON representation of the statistics.
|
72
|
+
#
|
73
|
+
# @returns [String] The statistics as JSON.
|
74
|
+
def to_json(...)
|
75
|
+
as_json.to_json(...)
|
76
|
+
end
|
59
77
|
end
|
60
78
|
end
|
61
79
|
end
|
data/readme.md
CHANGED
@@ -26,6 +26,15 @@ Please see the [project documentation](https://socketry.github.io/async-containe
|
|
26
26
|
|
27
27
|
Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
|
28
28
|
|
29
|
+
### v0.27.3
|
30
|
+
|
31
|
+
- Add log for starting child, including container statistics.
|
32
|
+
- Don't try to (log) "terminate 0 child processes" if there are none.
|
33
|
+
|
34
|
+
### v0.27.2
|
35
|
+
|
36
|
+
- More logging, especially around failure cases.
|
37
|
+
|
29
38
|
### v0.27.1
|
30
39
|
|
31
40
|
- Log caller and timeout when waiting on a child instance to exit, if it blocks.
|
@@ -60,12 +69,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
|
|
60
69
|
- Fix compatibility between <code class="language-ruby">Async::Container::Hybrid</code> and the health check.
|
61
70
|
- <code class="language-ruby">Async::Container::Generic\#initialize</code> passes unused arguments through to <code class="language-ruby">Async::Container::Group</code>.
|
62
71
|
|
63
|
-
### v0.20.0
|
64
|
-
|
65
|
-
- Improve container signal handling reliability by using `Thread.handle_interrupt` except at known safe points.
|
66
|
-
- Improved logging when child process fails and container startup.
|
67
|
-
- [Add `health_check_timeout` for detecting hung processes.](https://socketry.github.io/async-container/releases/index#add-health_check_timeout-for-detecting-hung-processes.)
|
68
|
-
|
69
72
|
## Contributing
|
70
73
|
|
71
74
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v0.27.3
|
4
|
+
|
5
|
+
- Add log for starting child, including container statistics.
|
6
|
+
- Don't try to (log) "terminate 0 child processes" if there are none.
|
7
|
+
|
8
|
+
## v0.27.2
|
9
|
+
|
10
|
+
- More logging, especially around failure cases.
|
11
|
+
|
3
12
|
## v0.27.1
|
4
13
|
|
5
14
|
- Log caller and timeout when waiting on a child instance to exit, if it blocks.
|
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.27.
|
4
|
+
version: 0.27.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.7.2
|
109
109
|
specification_version: 4
|
110
110
|
summary: Abstract container-based parallelism using threads and processes where appropriate.
|
111
111
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|