Sha256: 34cb42fb15b8c7ce3382e7124b22c92560f181b59847aedc8a8dfbc3ec0d2ce6

Contents?: true

Size: 1.03 KB

Versions: 160

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Appsignal
  class Hooks
    # @api private
    class UnicornHook < Appsignal::Hooks::Hook
      register :unicorn

      def dependencies_present?
        defined?(::Unicorn::HttpServer) &&
          defined?(::Unicorn::Worker)
      end

      def install
        # Make sure that appsignal is started and the last transaction
        # in a worker gets flushed.
        #
        # We'd love to be able to hook this into Unicorn in a less
        # intrusive way, but this is the best we can do given the
        # options we have.

        ::Unicorn::HttpServer.class_eval do
          alias worker_loop_without_appsignal worker_loop

          def worker_loop(worker)
            Appsignal.forked
            worker_loop_without_appsignal(worker)
          end
        end

        ::Unicorn::Worker.class_eval do
          alias close_without_appsignal close

          def close
            Appsignal.stop("unicorn")
            close_without_appsignal
          end
        end
      end
    end
  end
end

Version data entries

160 entries across 160 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.10 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.9-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.9 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.8-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.8 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.7 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.7-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.6 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.6-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.5-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.5 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.4-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.4 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.3-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.3 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.2-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.2 lib/appsignal/hooks/unicorn.rb
appsignal-2.11.1-java lib/appsignal/hooks/unicorn.rb
appsignal-2.11.1 lib/appsignal/hooks/unicorn.rb