Sha256: dd2bd1cd1f7dbb02d786194dc84abf889d514f48b940c5bf7e783dda52de3f25

Contents?: true

Size: 916 Bytes

Versions: 63

Compression:

Stored size: 916 Bytes

Contents

module Appsignal
  class Hooks
    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.new do |id|
          Appsignal.forked
        end

        ::Puma.cli_config.options[:before_worker_shutdown] ||= []
        ::Puma.cli_config.options[:before_worker_shutdown] << Proc.new 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

63 entries across 63 versions & 1 rubygems

Version Path
appsignal-2.0.6 lib/appsignal/hooks/puma.rb
appsignal-2.0.5 lib/appsignal/hooks/puma.rb
appsignal-2.0.5.beta.1 lib/appsignal/hooks/puma.rb
appsignal-2.1.0.alpha.3 lib/appsignal/hooks/puma.rb
appsignal-2.1.0.alpha.2 lib/appsignal/hooks/puma.rb
appsignal-2.1.0.alpha.1 lib/appsignal/hooks/puma.rb
appsignal-2.0.4 lib/appsignal/hooks/puma.rb
appsignal-2.0.3 lib/appsignal/hooks/puma.rb
appsignal-2.0.2 lib/appsignal/hooks/puma.rb
appsignal-2.0.1 lib/appsignal/hooks/puma.rb
appsignal-2.0.0 lib/appsignal/hooks/puma.rb
appsignal-2.0.0.beta.1 lib/appsignal/hooks/puma.rb
appsignal-1.4.0.beta.1 lib/appsignal/hooks/puma.rb
appsignal-1.3.6 lib/appsignal/hooks/puma.rb
appsignal-1.3.6.beta.1 lib/appsignal/hooks/puma.rb
appsignal-1.3.5 lib/appsignal/hooks/puma.rb
appsignal-1.3.5.beta.1 lib/appsignal/hooks/puma.rb
appsignal-1.3.4 lib/appsignal/hooks/puma.rb
appsignal-1.3.3 lib/appsignal/hooks/puma.rb
appsignal-1.4.0.alpha.2 lib/appsignal/hooks/puma.rb