Class: Gitlab::Memory::Watchdog
- Inherits:
-
Object
- Object
- Gitlab::Memory::Watchdog
- Defined in:
- lib/gitlab/memory/watchdog.rb,
lib/gitlab/memory/watchdog/configurator.rb,
lib/gitlab/memory/watchdog/configuration.rb,
lib/gitlab/memory/watchdog/monitor_state.rb,
lib/gitlab/memory/watchdog/event_reporter.rb,
lib/gitlab/memory/watchdog/handlers/null_handler.rb,
lib/gitlab/memory/watchdog/handlers/puma_handler.rb,
lib/gitlab/memory/watchdog/sidekiq_event_reporter.rb,
lib/gitlab/memory/watchdog/handlers/sidekiq_handler.rb,
lib/gitlab/memory/watchdog/monitor/rss_memory_limit.rb,
lib/gitlab/memory/watchdog/monitor/heap_fragmentation.rb,
lib/gitlab/memory/watchdog/monitor/unique_memory_growth.rb
Overview
A background thread that monitors Ruby memory and calls into a handler when the Ruby process violates defined limits for an extended period of time.
Defined Under Namespace
Modules: Handlers, Monitor Classes: Configuration, Configurator, EventReporter, MonitorState, SidekiqEventReporter
Instance Method Summary collapse
- #call ⇒ Object
-
#configure {|configuration| ... } ⇒ Object
Configuration for Watchdog, see Gitlab::Memory::Watchdog::Configurator for examples.
-
#initialize ⇒ Watchdog
constructor
A new instance of Watchdog.
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Watchdog
Returns a new instance of Watchdog.
9 10 11 12 |
# File 'lib/gitlab/memory/watchdog.rb', line 9 def initialize @configuration = Configuration.new @alive = true end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/memory/watchdog.rb', line 21 def call event_reporter.started(log_labels) while @alive sleep(sleep_time_seconds) monitor end event_reporter.stopped(log_labels(memwd_reason: @stop_reason).compact) end |
#configure {|configuration| ... } ⇒ Object
Configuration for Watchdog, see Gitlab::Memory::Watchdog::Configurator for examples.
17 18 19 |
# File 'lib/gitlab/memory/watchdog.rb', line 17 def configure yield configuration end |
#stop ⇒ Object
33 34 35 36 |
# File 'lib/gitlab/memory/watchdog.rb', line 33 def stop stop_working(reason: 'background task stopped') handler.stop if handler.respond_to?(:stop) end |