20300: Update to Rails 7.0.
[arvados.git] / services / api / config / application.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require_relative "boot"
6
7 require "rails"
8 # Pick the frameworks you want:
9 require "active_model/railtie"
10 require "active_job/railtie"
11 require "active_record/railtie"
12 # require "active_storage/engine"
13 require "action_controller/railtie"
14 require "action_mailer/railtie"
15 # require "action_mailbox/engine"
16 # require "action_text/engine"
17 require "action_view/railtie"
18 # require "action_cable/engine"
19 require "rails/test_unit/railtie"
20
21 # Require the gems listed in Gemfile, including any gems
22 # you've limited to :test, :development, or :production.
23 Bundler.require(*Rails.groups)
24
25 if ENV["ARVADOS_RAILS_LOG_TO_STDOUT"]
26   Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
27 end
28
29 module Server
30   class Application < Rails::Application
31
32     require_relative "arvados_config.rb"
33
34     # Initialize configuration defaults for specified Rails version.
35     config.load_defaults 6.1
36
37     # Configuration for the application, engines, and railties goes here.
38     #
39     # These settings can be overridden in specific environments using the files
40     # in config/environments, which are processed later.
41     #
42     # config.time_zone = "Central Time (US & Canada)"
43     # config.eager_load_paths << Rails.root.join("extras")
44
45     # We use db/structure.sql instead of db/schema.rb.
46     config.active_record.schema_format = :sql
47
48     config.eager_load = true
49
50     config.active_support.test_order = :sorted
51
52     # container_request records can contain arbitrary data structures
53     # in mounts.*.content, so rails must not munge them.
54     config.action_dispatch.perform_deep_munge = false
55
56     # force_ssl's redirect-to-https feature doesn't work when the
57     # client supplies a port number, and prevents arvados-controller
58     # from connecting to Rails internally via plain http.
59     config.ssl_options = {redirect: false}
60
61     # Before using the filesystem backend for Rails.cache, check
62     # whether we own the relevant directory. If we don't, using it is
63     # likely to either fail or (if we're root) pollute it and cause
64     # other processes to fail later.
65     default_cache_path = Rails.root.join('tmp', 'cache')
66     if not File.owned?(default_cache_path)
67       if File.exist?(default_cache_path)
68         why = "owner (uid=#{File::Stat.new(default_cache_path).uid}) " +
69           "is not me (uid=#{Process.euid})"
70       else
71         why = "does not exist"
72       end
73       STDERR.puts("Defaulting to memory cache, " +
74                   "because #{default_cache_path} #{why}")
75       config.cache_store = :memory_store
76     else
77       require Rails.root.join('lib/safer_file_store')
78       config.cache_store = ::SaferFileStore.new(default_cache_path)
79     end
80   end
81 end