1 require_relative "boot"
3 # Guard against deployments with old-style application.yml configurations
4 # Otherwise, admins might not be aware that they are now silently ignored
5 # and major problems could occur
6 # rubocop:disable Rails/Output, Rails/Exit
7 if File.exist?(File.expand_path("application.yml", __dir__))
8 puts "The config/application.yml file is no longer supported"
9 puts "Default settings are now found in config/settings.yml and you can override these in config/settings.local.yml"
10 puts "To prevent unexpected behaviour, please copy any custom settings to config/settings.local.yml"
11 puts " and then remove your config/application.yml file."
14 # rubocop:enable Rails/Output, Rails/Exit
16 # Set the STATUS constant from the environment, if it matches a recognized value
18 :online, # online and operating normally
19 :api_readonly, # site online but API in read-only mode
20 :api_offline, # site online but API offline
21 :database_readonly, # database and site in read-only mode
22 :database_offline, # database offline with site in emergency mode
23 :gpx_offline # gpx storage offline
26 status = if ENV["STATUS"] && ALLOWED_STATUS.include?(ENV["STATUS"].to_sym)
31 Object.const_set("STATUS", status)
33 if STATUS == :database_offline
34 require "action_controller/railtie"
35 require "action_mailer/railtie"
36 require "active_model/railtie"
37 require "sprockets/railtie"
38 require "rails/test_unit/railtie"
43 # Require the gems listed in Gemfile, including any gems
44 # you've limited to :test, :development, or :production.
45 Bundler.require(*Rails.groups)
48 class Application < Rails::Application
49 # Initialize configuration defaults for originally generated Rails version.
50 config.load_defaults 5.2
52 # Settings in config/environments/* take precedence over those specified here.
53 # Application configuration can go into files in config/initializers
54 # -- all .rb files in that directory are automatically loaded after loading
55 # the framework and any gems in your application.
57 # Custom directories with classes and modules you want to be autoloadable.
58 config.autoload_paths += %W[#{config.root}/lib]
60 # This defaults to true from rails 5.0 but our code doesn't comply
61 # with it at all so we turn it off
62 config.active_record.belongs_to_required_by_default = false
64 # Use SQL instead of Active Record's schema dumper when creating the database.
65 # This is necessary if your schema can't be completely dumped by the schema dumper,
66 # like if you have constraints or database-specific column types
67 config.active_record.schema_format = :sql unless STATUS == :database_offline
69 # Don't eager load models when the database is offline
70 config.paths["app/models"].skip_eager_load! if STATUS == :database_offline
72 # Use memcached for caching if required
73 config.cache_store = :mem_cache_store, Settings.memcache_servers, { :namespace => "rails:cache" } if Settings.key?(:memcache_servers)
75 # Use logstash for logging if required
76 if Settings.key?(:logstash_path)
77 config.logstasher.enabled = true
78 config.logstasher.suppress_app_log = false
79 config.logstasher.logger_path = Settings.logstash_path
80 config.logstasher.log_controller_parameters = true