mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 08:38:04 +08:00
This PR adds Pitchfork, as we want to move away from Unicorn ultimately. Unicorn still boots by default, so there should be no disruption for anyone. To use Pitchfork instead of Unicorn, the `RUN_PITCHFORK` environment variable must be set. This will make `bin/rails s` and `config/unicorn_launcher` boot Pitchfork. `unicorn_launcher` was patched because that way we can easily switch between Unicorn and Pitchfork without having to change too many things on the infra side. The upgrader from the `docker_manager` plugin doesn’t work yet with Pitchfork. This will be addressed in a future PR.
14 lines
712 B
Ruby
14 lines
712 B
Ruby
# frozen_string_literal: true
|
|
|
|
# See https://github.com/Shopify/pitchfork/blob/18869d2f02549a54d7b2db6e0351e7fa71e95546/lib/pitchfork.rb#L120
|
|
# Pitchfork originally logs backtrace line by line with `exc.backtrace.each { |line| logger.error(line) }`.
|
|
# However, that means we get a separate logstash message for each backtrace which isn't what we want. The
|
|
# monkey patch here overrides Pitchfork's logging of error so that we log the error and backtrace in a
|
|
# single message.
|
|
module Pitchfork
|
|
def self.log_error(logger, prefix, exc)
|
|
message = exc.message
|
|
message = message.dump if /[[:cntrl:]]/ =~ message
|
|
logger.error "#{prefix}: #{message} (#{exc.class})\n#{exc.backtrace.join("\n")}"
|
|
end
|
|
end
|