forest_admin_rpc_agent 1.16.2 → 1.16.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
- data/lib/forest_admin_rpc_agent/routes/sse.rb +20 -6
- data/lib/forest_admin_rpc_agent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9d8fdc26446a759cedb1a137693f7597a550ce685431a2d9f2489f86505c048f
|
|
4
|
+
data.tar.gz: 68580cdf123de1117fe8f6f515bf92feafd83d866f1e60fbb596805c3e70cca8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e108b68ce5a2c871a74a22f32dd10c4500bb4f474ffa3d3680cac17d364ecf7246f57dff9cb9fab4661bf7b36a4e28e1f30fb5559162da980e2cab018343e53a
|
|
7
|
+
data.tar.gz: 26f054f1d7ab8748e529cb12d5e5e8550d7eae3e822643cf904d7d5488307986915d0b3fc37948a99877cc697c10c3ca5f22f252ff3908756147e903a922f034
|
|
@@ -39,11 +39,14 @@ module ForestAdminRpcAgent
|
|
|
39
39
|
stream(:keep_open) do |out|
|
|
40
40
|
should_continue = true
|
|
41
41
|
server_stopped = false
|
|
42
|
-
|
|
42
|
+
received_signal = nil
|
|
43
|
+
stop_proc = proc do |sig|
|
|
43
44
|
should_continue = false
|
|
44
45
|
server_stopped = true
|
|
46
|
+
received_signal = sig
|
|
45
47
|
end
|
|
46
|
-
|
|
48
|
+
original_int_handler = trap('INT', stop_proc)
|
|
49
|
+
original_term_handler = trap('TERM', stop_proc)
|
|
47
50
|
|
|
48
51
|
begin
|
|
49
52
|
streamer = SseStreamer.new(out)
|
|
@@ -66,8 +69,12 @@ module ForestAdminRpcAgent
|
|
|
66
69
|
# Client disconnected normally
|
|
67
70
|
ForestAdminRpcAgent::Facades::Container.logger&.log('Debug', "[SSE] Client disconnected: #{e.message}")
|
|
68
71
|
ensure
|
|
69
|
-
trap('INT',
|
|
72
|
+
trap('INT', original_int_handler)
|
|
73
|
+
trap('TERM', original_term_handler)
|
|
70
74
|
out.close if out.respond_to?(:close)
|
|
75
|
+
|
|
76
|
+
# Re-send the signal to allow proper server shutdown
|
|
77
|
+
Process.kill(received_signal, Process.pid) if received_signal
|
|
71
78
|
end
|
|
72
79
|
end
|
|
73
80
|
end
|
|
@@ -90,11 +97,14 @@ module ForestAdminRpcAgent
|
|
|
90
97
|
|
|
91
98
|
should_continue = true
|
|
92
99
|
server_stopped = false
|
|
93
|
-
|
|
100
|
+
received_signal = nil
|
|
101
|
+
stop_proc = proc do |sig|
|
|
94
102
|
should_continue = false
|
|
95
103
|
server_stopped = true
|
|
104
|
+
received_signal = sig
|
|
96
105
|
end
|
|
97
|
-
|
|
106
|
+
original_int_handler = trap('INT', stop_proc)
|
|
107
|
+
original_term_handler = trap('TERM', stop_proc)
|
|
98
108
|
|
|
99
109
|
body = Enumerator.new do |yielder|
|
|
100
110
|
stream = SseStreamer.new(yielder)
|
|
@@ -123,8 +133,12 @@ module ForestAdminRpcAgent
|
|
|
123
133
|
ForestAdminRpcAgent::Facades::Container.logger&.log('Error', "[SSE] Unexpected error: #{e.message}")
|
|
124
134
|
ForestAdminRpcAgent::Facades::Container.logger&.log('Error', e.backtrace.join("\n"))
|
|
125
135
|
ensure
|
|
126
|
-
trap('INT',
|
|
136
|
+
trap('INT', original_int_handler)
|
|
137
|
+
trap('TERM', original_term_handler)
|
|
127
138
|
ForestAdminRpcAgent::Facades::Container.logger&.log('Debug', '[SSE] Stream stopped')
|
|
139
|
+
|
|
140
|
+
# Re-send the signal to allow proper server shutdown
|
|
141
|
+
Process.kill(received_signal, Process.pid) if received_signal
|
|
128
142
|
end
|
|
129
143
|
end
|
|
130
144
|
|