1 require_relative "boot"
3 # Set the STATUS constant from the environment, if it matches a recognized value
5 :online, # online and operating normally
6 :api_readonly, # site online but API in read-only mode
7 :api_offline, # site online but API offline
8 :database_readonly, # database and site in read-only mode
9 :database_offline, # database offline with site in emergency mode
10 :gpx_offline # gpx storage offline
13 status = if ENV["STATUS"] && ALLOWED_STATUS.include?(ENV["STATUS"].to_sym)
18 Object.const_set("STATUS", status)
20 if STATUS == :database_offline
21 require "action_controller/railtie"
22 require "action_mailer/railtie"
23 require "active_model/railtie"
24 require "sprockets/railtie"
25 require "rails/test_unit/railtie"
30 # Require the gems listed in Gemfile, including any gems
31 # you've limited to :test, :development, or :production.
32 Bundler.require(*Rails.groups)
35 class Application < Rails::Application
36 # Initialize configuration defaults for originally generated Rails version.
37 config.load_defaults 5.2
39 # Settings in config/environments/* take precedence over those specified here.
40 # Application configuration can go into files in config/initializers
41 # -- all .rb files in that directory are automatically loaded after loading
42 # the framework and any gems in your application.
44 # Custom directories with classes and modules you want to be autoloadable.
45 config.autoload_paths += %W[#{config.root}/lib]
47 # This defaults to true from rails 5.0 but our code doesn't comply
48 # with it at all so we turn it off
49 config.active_record.belongs_to_required_by_default = false
51 # Use SQL instead of Active Record's schema dumper when creating the database.
52 # This is necessary if your schema can't be completely dumped by the schema dumper,
53 # like if you have constraints or database-specific column types
54 config.active_record.schema_format = :sql unless STATUS == :database_offline
56 # Don't eager load models when the database is offline
57 config.paths["app/models"].skip_eager_load! if STATUS == :database_offline
59 # Use memcached for caching if required
60 config.cache_store = :mem_cache_store, Settings.memcache_servers, { :namespace => "rails:cache" } if Settings.key?(:memcache_servers)
62 # Use logstash for logging if required
63 if Settings.key?(:logstash_path)
64 config.logstasher.enabled = true
65 config.logstasher.suppress_app_log = false
66 config.logstasher.logger_path = Settings.logstash_path
67 config.logstasher.log_controller_parameters = true