Skip to content

Commit

Permalink
DEV: disable async logging in development on broken Ruby
Browse files Browse the repository at this point in the history
Ruby 2.5.3 has an upatched issue that crashes unicorn after fork:

https://bugs.ruby-lang.org/issues/14634

This will be patched in 2.5.4 however for now just warn people dev is slower
and disable async logging on the older rubies
  • Loading branch information
SamSaffron committed Feb 21, 2019
1 parent 8a3d12d commit 8745f78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ GEM
logstash-event (1.2.02)
logstash-logger (0.26.1)
logstash-event (~> 1.2)
logster (2.1.0)
logster (2.1.1)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down
9 changes: 9 additions & 0 deletions config/initializers/100-logster.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
if Rails.env.development? && RUBY_VERSION.match?(/^2\.5\.[23]/)
STDERR.puts "WARNING: Discourse development environment runs slower on Ruby 2.5.3 or below"
STDERR.puts "We recommend you upgrade to Ruby 2.6.1 for the optimal development performance"

# we have to used to older and slower version of the logger cause the new one exposes a Ruby bug in
# the Queue class which causes segmentation faults
Logster::Scheduler.disable
end

if Rails.env.development? && !Sidekiq.server? && ENV["RAILS_LOGS_STDOUT"] == "1"
console = ActiveSupport::Logger.new(STDOUT)
original_logger = Rails.logger.chained.first
Expand Down

2 comments on commit 8745f78

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/logster-2-1-0-causes-segfault-running-unicorn-in-discourse-dev-docker-image/109265/13

@SamSaffron
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking on ruby bugs for help here https://bugs.ruby-lang.org/issues/15617

Please sign in to comment.