Skip to content

Commit 6864651

Browse files
committed
Memory monitor documentation.
1 parent 5bdb79d commit 6864651

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

context/memory-monitor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ service "supervisor" do
2828
Async::Container::Supervisor::MemoryMonitor.new(
2929
# Check worker memory every 10 seconds:
3030
interval: 10,
31-
31+
3232
# Restart workers exceeding 500MB:
3333
maximum_size_limit: 1024 * 1024 * 500
3434
)

guides/memory-monitor/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ service "supervisor" do
2828
Async::Container::Supervisor::MemoryMonitor.new(
2929
# Check worker memory every 10 seconds:
3030
interval: 10,
31-
31+
3232
# Restart workers exceeding 500MB:
3333
maximum_size_limit: 1024 * 1024 * 500
3434
)

lib/async/container/supervisor/process_monitor.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ module Supervisor
1515
# by tracking the parent process ID (ppid), which is more efficient than tracking
1616
# individual processes.
1717
class ProcessMonitor
18-
# Create a new process monitor.
19-
#
20-
# @parameter interval [Integer] The interval in seconds at which to log process metrics.
21-
# @parameter ppid [Integer] The parent process ID to monitor. If nil, uses the current process to capture its children.
22-
def initialize(interval: 60, ppid: nil)
23-
@interval = interval
24-
@ppid = ppid || Process.ppid
25-
end
18+
# Create a new process monitor.
19+
#
20+
# @parameter interval [Integer] The interval in seconds at which to log process metrics.
21+
# @parameter ppid [Integer] The parent process ID to monitor. If nil, uses the current process to capture its children.
22+
def initialize(interval: 60, ppid: nil)
23+
@interval = interval
24+
@ppid = ppid || Process.ppid
25+
end
2626

2727
# @attribute [Integer] The parent process ID being monitored.
2828
attr :ppid
@@ -68,21 +68,21 @@ def status(call)
6868
# Periodically captures and logs process metrics for the entire process tree.
6969
#
7070
# @returns [Async::Task] The task that is running the process monitor.
71-
def run
72-
Async do
73-
while true
74-
metrics = self.metrics
75-
76-
# Log each process individually for better searchability in log platforms:
77-
metrics.each do |process_id, general|
78-
Console.info(self, "Process metrics captured.", general: general)
71+
def run
72+
Async do
73+
while true
74+
metrics = self.metrics
75+
76+
# Log each process individually for better searchability in log platforms:
77+
metrics.each do |process_id, general|
78+
Console.info(self, "Process metrics captured.", general: general)
79+
end
80+
81+
sleep(@interval)
7982
end
80-
81-
sleep(@interval)
8283
end
8384
end
8485
end
85-
end
8686
end
8787
end
8888
end

0 commit comments

Comments
 (0)