Sha256: 636fc5df462dea06f0155d922d1de44cb0e036f3e78a5b6a031ce354b4cc6fbf

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

require 'pitchfork/shared_memory'

module Pitchfork
  module Info
    @workers_count = 0

    class << self
      attr_accessor :workers_count

      def live_workers_count
        now = Pitchfork.time_now(true)
        (0...workers_count).count do |nr|
          SharedMemory.worker_deadline(nr).value > now
        end
      end

      # Returns true if the server is shutting down.
      # This can be useful to implement health check endpoints, so they
      # can fail immediately after TERM/QUIT/INT was received by the master
      # process.
      # Otherwise they may succeed while Pitchfork is draining requests causing
      # more requests to be sent.
      def shutting_down?
        SharedMemory.shutting_down?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pitchfork-0.6.0 lib/pitchfork/info.rb