1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require_relative 'boot'
8 # Pick only the frameworks we need:
9 require "active_model/railtie"
10 require "active_job/railtie"
11 require "active_record/railtie"
12 require "action_controller/railtie"
13 require "action_mailer/railtie"
14 require "action_view/railtie"
15 require "sprockets/railtie"
16 require "rails/test_unit/railtie"
17 # Skipping the following:
18 # * ActionCable (new in Rails 5.0) as it adds '/cable' routes that we're not using
19 # * ActiveStorage (new in Rails 5.1)
25 verbose_orig = $VERBOSE
30 $VERBOSE = verbose_orig
37 # If you precompile assets before deploying to production, use this line
38 Bundler.require(*Rails.groups(:assets => %w(development test)))
39 # If you want your assets lazily compiled in production, use this line
40 # Bundler.require(:default, :assets, Rails.env)
44 if ENV["ARVADOS_RAILS_LOG_TO_STDOUT"]
45 Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
49 class Application < Rails::Application
50 # The following is to avoid SafeYAML's warning message
51 SafeYAML::OPTIONS[:default_mode] = :safe
53 require_relative "arvados_config.rb"
55 # Settings in config/environments/* take precedence over those specified here.
56 # Application configuration should go into files in config/initializers
57 # -- all .rb files in that directory are automatically loaded.
59 # Custom directories with classes and modules you want to be autoloadable.
60 # config.autoload_paths += %W(#{config.root}/extras)
62 # Only load the plugins named here, in the order given (default is alphabetical).
63 # :all can be used as a placeholder for all plugins not explicitly named.
64 # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
66 # Activate observers that should always be running.
67 # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
68 config.active_record.schema_format = :sql
70 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
71 # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
72 # config.i18n.default_locale = :de
74 # Configure sensitive parameters which will be filtered from the log file.
75 config.filter_parameters += [:password]
77 # Load entire application at startup.
78 config.eager_load = true
80 config.active_support.test_order = :sorted
82 config.action_dispatch.perform_deep_munge = false
84 # force_ssl's redirect-to-https feature doesn't work when the
85 # client supplies a port number, and prevents arvados-controller
86 # from connecting to Rails internally via plain http.
87 config.ssl_options = {redirect: false}
89 I18n.enforce_available_locales = false
91 # Before using the filesystem backend for Rails.cache, check
92 # whether we own the relevant directory. If we don't, using it is
93 # likely to either fail or (if we're root) pollute it and cause
94 # other processes to fail later.
95 default_cache_path = Rails.root.join('tmp', 'cache')
96 if not File.owned?(default_cache_path)
97 if File.exist?(default_cache_path)
98 why = "owner (uid=#{File::Stat.new(default_cache_path).uid}) " +
99 "is not me (uid=#{Process.euid})"
101 why = "does not exist"
103 STDERR.puts("Defaulting to memory cache, " +
104 "because #{default_cache_path} #{why}")
105 config.cache_store = :memory_store
107 require Rails.root.join('lib/safer_file_store')
108 config.cache_store = ::SaferFileStore.new(default_cache_path)