async-container-supervisor 0.9.1 → 0.9.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/bake/async/container/supervisor.rb +7 -1
- data/lib/async/container/supervisor/client.rb +6 -2
- data/lib/async/container/supervisor/connection.rb +3 -2
- data/lib/async/container/supervisor/memory_monitor.rb +20 -10
- data/lib/async/container/supervisor/version.rb +1 -1
- data/lib/async/container/supervisor/worker.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: 4765d4a1500ef475808f032d7140aacd3beac8e939c68b34c3884d0cee53bef3
|
|
4
|
+
data.tar.gz: fc6fd02c0376c43685f32a2556122fa7c10d36388411241927f6bd58bf9a741f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43c99bc5e998157859b494039c62e44bbc2469a82824f482a6d5918c658c35a0e173a3f5c910f5a947b530bbbccdf8a0e1a7eb42a14f54ac268f6d4581b63a43
|
|
7
|
+
data.tar.gz: 8444b007dbdfc4a8ecfd6834cdf5e19d73939421ababec4be2dedc5db5d5d6551c29b9264259966df2d637b162dd0a63f847a7dbefdc683c429ee27a534d3b76
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -44,7 +44,13 @@ def memory_sample(duration: 10, connection_id:)
|
|
|
44
44
|
operation = {do: :memory_sample, duration: duration}
|
|
45
45
|
|
|
46
46
|
# Use the forward operation to proxy the request to a worker:
|
|
47
|
-
|
|
47
|
+
response = connection.call(do: :forward, operation: operation, connection_id: connection_id)
|
|
48
|
+
|
|
49
|
+
if response && response.key?(:data)
|
|
50
|
+
JSON.parse(response[:data], symbolize_names: true)
|
|
51
|
+
else
|
|
52
|
+
response
|
|
53
|
+
end
|
|
48
54
|
end
|
|
49
55
|
end
|
|
50
56
|
|
|
@@ -48,11 +48,11 @@ module Async
|
|
|
48
48
|
|
|
49
49
|
# Run the client in a loop, reconnecting if necessary.
|
|
50
50
|
def run
|
|
51
|
-
Async(annotation: "Supervisor Client", transient: true) do
|
|
51
|
+
Async(annotation: "Supervisor Client", transient: true) do |task|
|
|
52
52
|
loop do
|
|
53
53
|
connection = connect!
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
connected_task = task.async do
|
|
56
56
|
connected!(connection)
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -61,6 +61,10 @@ module Async
|
|
|
61
61
|
Console.error(self, "Connection failed:", exception: error)
|
|
62
62
|
sleep(rand)
|
|
63
63
|
ensure
|
|
64
|
+
# Ensure any tasks that were created during connection are stopped:
|
|
65
|
+
connected_task&.stop
|
|
66
|
+
|
|
67
|
+
# Close the connection itself:
|
|
64
68
|
connection&.close
|
|
65
69
|
end
|
|
66
70
|
end
|
|
@@ -253,8 +253,9 @@ module Async
|
|
|
253
253
|
#
|
|
254
254
|
# @parameter message [Hash] The message to write.
|
|
255
255
|
def write(**message)
|
|
256
|
-
|
|
257
|
-
@stream.
|
|
256
|
+
raise IOError, "Connection is closed!" unless @stream
|
|
257
|
+
@stream&.write(JSON.dump(message) << "\n")
|
|
258
|
+
@stream&.flush # it is possible for @stream to become nil after the write call
|
|
258
259
|
end
|
|
259
260
|
|
|
260
261
|
# Read a message from the connection stream.
|
|
@@ -30,6 +30,9 @@ module Async
|
|
|
30
30
|
@options = options
|
|
31
31
|
|
|
32
32
|
@processes = Hash.new{|hash, key| hash[key] = Set.new.compare_by_identity}
|
|
33
|
+
|
|
34
|
+
# Queue to serialize cluster modifications to prevent race conditions:
|
|
35
|
+
@guard = Mutex.new
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
# @attribute [Memory::Leak::Cluster] The cluster of processes being monitored.
|
|
@@ -50,7 +53,10 @@ module Async
|
|
|
50
53
|
|
|
51
54
|
if connections.empty?
|
|
52
55
|
Console.debug(self, "Registering process.", child: {process_id: process_id})
|
|
53
|
-
|
|
56
|
+
# Queue the cluster modification to avoid race conditions:
|
|
57
|
+
@guard.synchronize do
|
|
58
|
+
self.add(process_id)
|
|
59
|
+
end
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
connections.add(connection)
|
|
@@ -66,7 +72,9 @@ module Async
|
|
|
66
72
|
|
|
67
73
|
if connections.empty?
|
|
68
74
|
Console.debug(self, "Removing process.", child: {process_id: process_id})
|
|
69
|
-
@
|
|
75
|
+
@guard.synchronize do
|
|
76
|
+
@cluster.remove(process_id)
|
|
77
|
+
end
|
|
70
78
|
end
|
|
71
79
|
end
|
|
72
80
|
end
|
|
@@ -119,14 +127,16 @@ module Async
|
|
|
119
127
|
def run
|
|
120
128
|
Async do
|
|
121
129
|
Loop.run(interval: @interval) do
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
@guard.synchronize do
|
|
131
|
+
# This block must return true if the process was killed.
|
|
132
|
+
@cluster.check! do |process_id, monitor|
|
|
133
|
+
Console.error(self, "Memory leak detected!", child: {process_id: process_id}, monitor: monitor)
|
|
134
|
+
|
|
135
|
+
begin
|
|
136
|
+
memory_leak_detected(process_id, monitor)
|
|
137
|
+
rescue => error
|
|
138
|
+
Console.error(self, "Failed to handle memory leak!", child: {process_id: process_id}, exception: error)
|
|
139
|
+
end
|
|
130
140
|
end
|
|
131
141
|
end
|
|
132
142
|
end
|
data/readme.md
CHANGED
|
@@ -26,6 +26,10 @@ 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-supervisor/releases/index) for all releases.
|
|
28
28
|
|
|
29
|
+
### v0.9.3
|
|
30
|
+
|
|
31
|
+
- Serialize `register`/`remove` and `check!` operations in `MemoryMonitor`.
|
|
32
|
+
|
|
29
33
|
### v0.9.1
|
|
30
34
|
|
|
31
35
|
- Close `Call` queue if asynchronous call fails during dispatch - further messages will fail with `ClosedQueueError`.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async-container-supervisor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
154
|
- !ruby/object:Gem::Version
|
|
155
155
|
version: '0'
|
|
156
156
|
requirements: []
|
|
157
|
-
rubygems_version:
|
|
157
|
+
rubygems_version: 4.0.3
|
|
158
158
|
specification_version: 4
|
|
159
159
|
summary: A supervisor for managing multiple container processes.
|
|
160
160
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|