summaryrefslogtreecommitdiff
path: root/lib/gitlab/memory/watchdog/handlers/puma_handler.rb
blob: fffd91733c82729a9e0048407201834ebcefa510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Gitlab
  module Memory
    class Watchdog
      module Handlers
        # This handler invokes Puma's graceful termination handler, which takes
        # into account a configurable grace period during which a process may
        # remain unresponsive to a SIGTERM.
        class PumaHandler
          def initialize(puma_options = ::Puma.cli_config.options)
            @worker = ::Puma::Cluster::WorkerHandle.new(0, $$, 0, puma_options)
          end

          def call
            @worker.term
            true
          end
        end
      end
    end
  end
end