Merge branch '8784-dir-listings'
[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 File.expand_path('../boot', __FILE__)
6
7 require 'rails/all'
8 require 'digest'
9
10 module Kernel
11   def suppress_warnings
12     verbose_orig = $VERBOSE
13     begin
14       $VERBOSE = nil
15       yield
16     ensure
17       $VERBOSE = verbose_orig
18     end
19   end
20 end
21
22 if defined?(Bundler)
23   suppress_warnings do
24     # If you precompile assets before deploying to production, use this line
25     Bundler.require(*Rails.groups(:assets => %w(development test)))
26     # If you want your assets lazily compiled in production, use this line
27     # Bundler.require(:default, :assets, Rails.env)
28   end
29 end
30
31 module Server
32   class Application < Rails::Application
33     # Settings in config/environments/* take precedence over those specified here.
34     # Application configuration should go into files in config/initializers
35     # -- all .rb files in that directory are automatically loaded.
36
37     # Custom directories with classes and modules you want to be autoloadable.
38     # config.autoload_paths += %W(#{config.root}/extras)
39
40     # Only load the plugins named here, in the order given (default is alphabetical).
41     # :all can be used as a placeholder for all plugins not explicitly named.
42     # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
43
44     # Activate observers that should always be running.
45     # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
46     config.active_record.schema_format = :sql
47
48     # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
49     # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
50     # config.i18n.default_locale = :de
51
52     # Configure sensitive parameters which will be filtered from the log file.
53     config.filter_parameters += [:password]
54
55     # Load entire application at startup.
56     config.eager_load = true
57
58     config.active_record.raise_in_transactional_callbacks = true
59
60     config.active_support.test_order = :sorted
61
62     config.action_dispatch.perform_deep_munge = false
63
64     I18n.enforce_available_locales = false
65
66     # Before using the filesystem backend for Rails.cache, check
67     # whether we own the relevant directory. If we don't, using it is
68     # likely to either fail or (if we're root) pollute it and cause
69     # other processes to fail later.
70     default_cache_path = Rails.root.join('tmp', 'cache')
71     if not File.owned?(default_cache_path)
72       if File.exist?(default_cache_path)
73         why = "owner (uid=#{File::Stat.new(default_cache_path).uid}) " +
74           "is not me (uid=#{Process.euid})"
75       else
76         why = "does not exist"
77       end
78       STDERR.puts("Defaulting to memory cache, " +
79                   "because #{default_cache_path} #{why}")
80       config.cache_store = :memory_store
81     end
82   end
83 end