21165: Uninstalls WB1 from single host installations too.
[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 "sprockets/railtie"
20 require "rails/test_unit/railtie"
21
22 # Require the gems listed in Gemfile, including any gems
23 # you've limited to :test, :development, or :production.
24 Bundler.require(*Rails.groups)
25
26 if ENV["ARVADOS_RAILS_LOG_TO_STDOUT"]
27   Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
28 end
29
30 module Server
31   class Application < Rails::Application
32
33     require_relative "arvados_config.rb"
34
35     # Initialize configuration defaults for specified Rails version.
36     config.load_defaults 7.0
37
38     # Configuration for the application, engines, and railties goes here.
39     #
40     # These settings can be overridden in specific environments using the files
41     # in config/environments, which are processed later.
42     #
43     # config.time_zone = "Central Time (US & Canada)"
44     # config.eager_load_paths << Rails.root.join("extras")
45
46     # We use db/structure.sql instead of db/schema.rb.
47     config.active_record.schema_format = :sql
48
49     config.eager_load = true
50
51     config.active_support.test_order = :sorted
52
53     # container_request records can contain arbitrary data structures
54     # in mounts.*.content, so rails must not munge them.
55     config.action_dispatch.perform_deep_munge = false
56
57     # force_ssl's redirect-to-https feature doesn't work when the
58     # client supplies a port number, and prevents arvados-controller
59     # from connecting to Rails internally via plain http.
60     config.ssl_options = {redirect: false}
61
62     # This will change to 7.0 in a future release when there is no
63     # longer a possibility of rolling back to Arvados 2.7 (Rails 5.2)
64     # which cannot read 7.0-format cache files.
65     config.active_support.cache_format_version = 6.1
66
67     # Before using the filesystem backend for Rails.cache, check
68     # whether we own the relevant directory. If we don't, using it is
69     # likely to either fail or (if we're root) pollute it and cause
70     # other processes to fail later.
71     default_cache_path = Rails.root.join('tmp', 'cache')
72     if not File.owned?(default_cache_path)
73       if File.exist?(default_cache_path)
74         why = "owner (uid=#{File::Stat.new(default_cache_path).uid}) " +
75           "is not me (uid=#{Process.euid})"
76       else
77         why = "does not exist"
78       end
79       STDERR.puts("Defaulting to memory cache, " +
80                   "because #{default_cache_path} #{why}")
81       config.cache_store = :memory_store
82     else
83       require Rails.root.join('lib/safer_file_store')
84       config.cache_store = ::SaferFileStore.new(default_cache_path)
85     end
86   end
87 end