"Fossies" - the Fresh Open Source Software Archive

Member "discourse-2.8.3/config/initializers/005-site_settings.rb" (14 Apr 2022, 1091 Bytes) of package /linux/www/discourse-2.8.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 
    3 # load up git version into memory
    4 # this way if it changes underneath we still have
    5 # the original version
    6 Discourse.git_version
    7 
    8 if GlobalSetting.skip_redis?
    9   # Requiring this file explicitly prevents it from being autoloaded and so the
   10   # provider attribute is not cleared
   11   require File.expand_path('../../../app/models/site_setting', __FILE__)
   12 
   13   require 'site_settings/local_process_provider'
   14   Rails.cache = Discourse.cache
   15   SiteSetting.provider = SiteSettings::LocalProcessProvider.new
   16   return
   17 end
   18 
   19 reload_settings = lambda {
   20   RailsMultisite::ConnectionManagement.safe_each_connection do
   21     begin
   22       SiteSetting.refresh!
   23 
   24       unless String === SiteSetting.push_api_secret_key && SiteSetting.push_api_secret_key.length == 32
   25         SiteSetting.push_api_secret_key = SecureRandom.hex
   26       end
   27     rescue ActiveRecord::StatementInvalid
   28       # This will happen when migrating a new database
   29     end
   30   end
   31 }
   32 
   33 reload_settings.call
   34 
   35 if !Rails.configuration.cache_classes
   36   ActiveSupport::Reloader.to_prepare do
   37     reload_settings.call
   38   end
   39 end