Sha256: 8ddb7e6d0e1a53ffc2d4df5ad7ee054715d7bbd2cc5f45cc107a3c72c3106d6e

Contents?: true

Size: 990 Bytes

Versions: 53

Compression:

Stored size: 990 Bytes

Contents

module Appsignal
  class Hooks
    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
            close_without_appsignal
          end
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
appsignal-1.1.5.beta.1 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.4 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.4.beta.3 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.4.beta.2 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.4.beta.1 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.3 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.3.beta.1 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.2 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.1 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.1.beta.1 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.0.beta.13 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.0.beta.12 lib/appsignal/hooks/unicorn.rb
appsignal-1.0.7 lib/appsignal/hooks/unicorn.rb
appsignal-1.0.6 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.0.beta.11 lib/appsignal/hooks/unicorn.rb
appsignal-1.0.6.beta.4 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.0.beta.10 lib/appsignal/hooks/unicorn.rb
appsignal-1.0.6.beta.3 lib/appsignal/hooks/unicorn.rb
appsignal-1.1.0.beta.9 lib/appsignal/hooks/unicorn.rb
appsignal-1.0.6.beta.2 lib/appsignal/hooks/unicorn.rb