Skip to content

Commit b32f2df

Browse files
Extra logging.
1 parent 3f54989 commit b32f2df

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

lib/async/container/controller.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ def setup(container)
9191
# Start the container unless it's already running.
9292
def start
9393
unless @container
94-
Console.info(self) {"Controller starting..."}
94+
Console.info(self, "Controller starting...")
9595
self.restart
9696
end
9797

98-
Console.info(self) {"Controller started..."}
98+
Console.info(self, "Controller started...")
9999
end
100100

101101
# Stop the container if it's running.
@@ -111,9 +111,9 @@ def restart
111111
if @container
112112
@notify&.restarting!
113113

114-
Console.debug(self) {"Restarting container..."}
114+
Console.info(self, "Restarting container...")
115115
else
116-
Console.debug(self) {"Starting container..."}
116+
Console.info(self, "Starting container...")
117117
end
118118

119119
container = self.create_container
@@ -127,13 +127,14 @@ def restart
127127
end
128128

129129
# Wait for all child processes to enter the ready state.
130-
Console.debug(self, "Waiting for startup...")
130+
Console.info(self, "Waiting for startup...")
131131
container.wait_until_ready
132-
Console.debug(self, "Finished startup.")
132+
Console.info(self, "Finished startup.")
133133

134134
if container.failed?
135135
@notify&.error!("Container failed to start!")
136136

137+
Console.info(self, "Stopping failed container...")
137138
container.stop(false)
138139

139140
raise SetupError, container
@@ -145,7 +146,7 @@ def restart
145146
container = nil
146147

147148
if old_container
148-
Console.debug(self, "Stopping old container...")
149+
Console.info(self, "Stopping old container...")
149150
old_container&.stop(@graceful_stop)
150151
end
151152

@@ -168,11 +169,11 @@ def reload
168169
end
169170

170171
# Wait for all child processes to enter the ready state.
171-
Console.debug(self, "Waiting for startup...")
172+
Console.info(self, "Waiting for startup...")
172173

173174
@container.wait_until_ready
174175

175-
Console.debug(self, "Finished startup.")
176+
Console.info(self, "Finished startup.")
176177

177178
if @container.failed?
178179
@notify.error!("Container failed to reload!")

lib/async/container/generic.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def wait_until_ready
139139
# Stop the children instances.
140140
# @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
141141
def stop(timeout = true)
142+
Console.info(self, "Stopping container...", timeout: timeout, caller: caller_locations)
143+
142144
@running = false
143145
@group.stop(timeout)
144146

@@ -184,6 +186,8 @@ def spawn(name: nil, restart: false, key: nil, health_check_timeout: nil, &block
184186

185187
begin
186188
status = @group.wait_for(child) do |message|
189+
Console.info(self, "Message received from child.", child: child, message: message, running: @running)
190+
187191
case message
188192
when :health_check!
189193
if health_check_timeout&.<(age_clock.total)
@@ -199,10 +203,10 @@ def spawn(name: nil, restart: false, key: nil, health_check_timeout: nil, &block
199203
end
200204

201205
if status.success?
202-
Console.debug(self) {"#{child} exited with #{status}"}
206+
Console.info(self, "Child exited successfully.", status: status, running: @running)
203207
else
204208
@statistics.failure!
205-
Console.error(self, status: status)
209+
Console.error(self, "Child exited with error!", status: status, running: @running)
206210
end
207211

208212
if restart
@@ -211,6 +215,11 @@ def spawn(name: nil, restart: false, key: nil, health_check_timeout: nil, &block
211215
break
212216
end
213217
end
218+
rescue => error
219+
Console.error(self, "Failure during child process management!", exception: error, running: @running)
220+
raise
221+
ensure
222+
Console.info(self, "Child process management loop exited.", running: @running)
214223
end.resume
215224

216225
return true

lib/async/container/group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def wait_for(channel)
232232

233233
def wait_for_children(duration = nil)
234234
# This log is a big noisy and doesn't really provide a lot of useful information.
235-
# Console.debug(self, "Waiting for children...", duration: duration, running: @running)
235+
Console.info(self, "Waiting for children...", duration: duration, running: @running)
236236

237237
unless @running.empty?
238238
# Maybe consider using a proper event loop here:

0 commit comments

Comments
 (0)