mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 05:07:20 +08:00
374ab82dd6
The logster initializer tries to adds RailsMultisite::Formatter to the STDOUT logger. In production, the lograge initializer then removes the RailsMultisite:Formatter because the JSON log will include the database.e10a74694a
used `Rails.application.reloader.to_prepare` to defer running the 100-logster initializer, which meant it ran **after** 101-lograge. This meant that we were writing JSON logs with a non-json text prefix. The `to_prepare` was added because our freedom-patches are now deferred using `to_prepare`, and some initializers were relying on the freedom patches. However, following1533cbb38b
, we decided to load the RailsMultisite freedom patch without `to_prepare`. Therefore, `005-site_settings` and `100-logster` no longer need to use `to_prepare`. Removing it means that these initializers are back to running in sequential order, and the logging issue will be resolved. The only remaining initializer which depends on freedom patches is `100-i18n`. I've added a comment to explain why.
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# load up git version into memory
|
|
# this way if it changes underneath we still have
|
|
# the original version
|
|
Discourse.git_version
|
|
|
|
if GlobalSetting.skip_redis?
|
|
# Requiring this file explicitly prevents it from being autoloaded and so the
|
|
# provider attribute is not cleared
|
|
require File.expand_path('../../../app/models/site_setting', __FILE__)
|
|
|
|
require 'site_settings/local_process_provider'
|
|
Rails.cache = Discourse.cache
|
|
SiteSetting.provider = SiteSettings::LocalProcessProvider.new
|
|
return
|
|
end
|
|
|
|
reload_settings = lambda {
|
|
RailsMultisite::ConnectionManagement.safe_each_connection do
|
|
begin
|
|
SiteSetting.refresh!
|
|
|
|
unless String === SiteSetting.push_api_secret_key && SiteSetting.push_api_secret_key.length == 32
|
|
SiteSetting.push_api_secret_key = SecureRandom.hex
|
|
end
|
|
rescue ActiveRecord::StatementInvalid
|
|
# This will happen when migrating a new database
|
|
end
|
|
end
|
|
}
|
|
|
|
reload_settings.call
|
|
|
|
if !Rails.configuration.cache_classes
|
|
ActiveSupport::Reloader.to_prepare do
|
|
reload_settings.call
|
|
end
|
|
end
|