2022-07-18 14:08:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
return unless Gitlab::Runtime.application?
|
|
|
|
return unless Gitlab::Utils.to_boolean(ENV['GITLAB_MEMORY_WATCHDOG_ENABLED'])
|
|
|
|
|
|
|
|
Gitlab::Cluster::LifecycleEvents.on_worker_start do
|
|
|
|
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
|
|
|
|
|
2022-08-01 14:12:02 -04:00
|
|
|
watchdog = Gitlab::Memory::Watchdog.new(
|
2022-07-18 14:08:47 -04:00
|
|
|
handler: handler, logger: Gitlab::AppLogger
|
2022-08-01 14:12:02 -04:00
|
|
|
)
|
|
|
|
Gitlab::BackgroundTask.new(watchdog).start
|
2022-07-18 14:08:47 -04:00
|
|
|
end
|