diff options
Diffstat (limited to 'config/initializers/memory_watchdog.rb')
-rw-r--r-- | config/initializers/memory_watchdog.rb | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/config/initializers/memory_watchdog.rb b/config/initializers/memory_watchdog.rb index ce8e5029e7a..99c5d61293f 100644 --- a/config/initializers/memory_watchdog.rb +++ b/config/initializers/memory_watchdog.rb @@ -1,35 +1,14 @@ # frozen_string_literal: true return unless Gitlab::Runtime.application? -return unless Gitlab::Utils.to_boolean(ENV['GITLAB_MEMORY_WATCHDOG_ENABLED']) +return unless Gitlab::Utils.to_boolean(ENV['GITLAB_MEMORY_WATCHDOG_ENABLED'], default: Gitlab::Runtime.puma?) Gitlab::Cluster::LifecycleEvents.on_worker_start do watchdog = Gitlab::Memory::Watchdog.new - max_strikes = ENV.fetch('GITLAB_MEMWD_MAX_STRIKES', 5).to_i - sleep_time_seconds = ENV.fetch('GITLAB_MEMWD_SLEEP_TIME_SEC', 60).to_i - max_mem_growth = ENV.fetch('GITLAB_MEMWD_MAX_MEM_GROWTH', 3.0).to_f - max_heap_frag = ENV.fetch('GITLAB_MEMWD_MAX_HEAP_FRAG', 0.5).to_f - - watchdog.configure do |config| - config.handler = - if Gitlab::Runtime.puma? - Gitlab::Memory::Watchdog::PumaHandler.new - elsif Gitlab::Runtime.sidekiq? - Gitlab::Memory::Watchdog::TermProcessHandler.new - else - Gitlab::Memory::Watchdog::NullHandler.instance - end - - config.logger = Gitlab::AppLogger - config.sleep_time_seconds = sleep_time_seconds - # config.monitor.use MonitorClass, args*, max_strikes:, kwargs**, &block - config.monitors.use Gitlab::Memory::Watchdog::Monitor::HeapFragmentation, - max_heap_fragmentation: max_heap_frag, - max_strikes: max_strikes - - config.monitors.use Gitlab::Memory::Watchdog::Monitor::UniqueMemoryGrowth, - max_mem_growth: max_mem_growth, - max_strikes: max_strikes + if Gitlab::Runtime.puma? + watchdog.configure(&Gitlab::Memory::Watchdog::Configurator.configure_for_puma) + elsif Gitlab::Runtime.sidekiq? + watchdog.configure(&Gitlab::Memory::Watchdog::Configurator.configure_for_sidekiq) end Gitlab::BackgroundTask.new(watchdog).start |