Sha256: 6837cd2441fb41931a921cbfe4c1baad58f177f70f8a254f5b0a65b3b2aced78

Contents?: true

Size: 929 Bytes

Versions: 38

Compression:

Stored size: 929 Bytes

Contents

module Appsignal
  class Hooks
    # @api private
    class PumaHook < Appsignal::Hooks::Hook
      register :puma

      def dependencies_present?
        defined?(::Puma) &&
          ::Puma.respond_to?(:cli_config) &&
          ::Puma.cli_config
      end

      def install
        ::Puma.cli_config.options[:before_worker_boot] ||= []
        ::Puma.cli_config.options[:before_worker_boot] << proc do |_id|
          Appsignal.forked
        end

        ::Puma.cli_config.options[:before_worker_shutdown] ||= []
        ::Puma.cli_config.options[:before_worker_shutdown] << proc do |_id|
          Appsignal.stop("puma before_worker_shutdown")
        end

        ::Puma::Cluster.class_eval do
          alias stop_workers_without_appsignal stop_workers

          def stop_workers
            Appsignal.stop("puma cluster")
            stop_workers_without_appsignal
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appsignal-2.5.3-java lib/appsignal/hooks/puma.rb
appsignal-2.5.3 lib/appsignal/hooks/puma.rb
appsignal-2.5.3.alpha.2 lib/appsignal/hooks/puma.rb
appsignal-2.5.3.alpha.2-java lib/appsignal/hooks/puma.rb
appsignal-2.5.3.alpha.1 lib/appsignal/hooks/puma.rb
appsignal-2.5.3.alpha.1-java lib/appsignal/hooks/puma.rb
appsignal-2.5.2-java lib/appsignal/hooks/puma.rb
appsignal-2.5.2 lib/appsignal/hooks/puma.rb
appsignal-2.5.1-java lib/appsignal/hooks/puma.rb
appsignal-2.5.1 lib/appsignal/hooks/puma.rb
appsignal-2.5.1.beta.1-java lib/appsignal/hooks/puma.rb
appsignal-2.5.1.beta.1 lib/appsignal/hooks/puma.rb
appsignal-2.5.0-java lib/appsignal/hooks/puma.rb
appsignal-2.5.0 lib/appsignal/hooks/puma.rb
appsignal-2.5.0.beta.1-java lib/appsignal/hooks/puma.rb
appsignal-2.5.0.beta.1 lib/appsignal/hooks/puma.rb
appsignal-2.5.0.alpha.1-java lib/appsignal/hooks/puma.rb
appsignal-2.5.0.alpha.1 lib/appsignal/hooks/puma.rb
appsignal-2.4.3 lib/appsignal/hooks/puma.rb
appsignal-2.4.2 lib/appsignal/hooks/puma.rb