Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/memory_watchdog.rb')
-rw-r--r--config/initializers/memory_watchdog.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/config/initializers/memory_watchdog.rb b/config/initializers/memory_watchdog.rb
new file mode 100644
index 00000000000..72779a18b10
--- /dev/null
+++ b/config/initializers/memory_watchdog.rb
@@ -0,0 +1,19 @@
+# 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
+
+ Gitlab::Memory::Watchdog.new(
+ handler: handler, logger: Gitlab::AppLogger
+ ).start
+end