summaryrefslogtreecommitdiff
path: root/config/environments/shared.rb
blob: e5bbc9e2375c4ab3b4672e02fdb4258441968ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true
require 'booru/config'

Rails.application.configure do
  # logging stuff, log to stdout or a file depending on how we're feeling today.
  config.log_formatter = ::Logger::Formatter.new
  config.eager_load = true

  if ENV['RAILS_LOG_TO_STDOUT'].present?
    config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
  else
    logger           = ActiveSupport::Logger.new(STDOUT)
    logger.formatter = config.log_formatter
    config.logger    = ActiveSupport::TaggedLogging.new(logger)
    config.logger.extend(ActiveSupport::Logger.broadcast(ActiveSupport::Logger.new(Rails.root.join('log', "#{Rails.env}.log"))))
    # config.logger = ActiveSupport::TaggedLogging.new(
    #  ActiveSupport::Logger.new(Rails.root.join('log', ))
    #)
    config.colorize_logging = false
  end

  # Specifies the header that your server uses for sending files.
  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  config.action_controller.asset_host = Booru::CONFIG.settings[:cdn_url_root]
  # Use Redis as the cache store
  config.active_record.cache_versioning = false
  config.cache_store = :redis_store, Booru::CONFIG.settings[:redis_url], { expires_in: 5.days }

  config.active_record.async_query_executor = :global_thread_pool
  # ElasticAPM has a lot of useless debug logging
  # Rails.application.config.elastic_apm.alert_logger = Logger.new(nil)
  # Rails.application.config.elastic_apm.logger = Logger.new(nil)

  config.active_record.encryption.key_derivation_salt = Booru::CONFIG.secrets[:key_derivation_salt]
  config.active_record.encryption.primary_key = Booru::CONFIG.secrets[:primary_key]

  config.flipflop.dashboard_access_filter = -> {
    head :forbidden unless can?(:manage, Flipflop)
  }

  config.active_record.encryption.support_unencrypted_data = true
end