require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module AppPush
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.0

    require_relative '../app/services/settings'
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
    config.i18n.default_locale = 'zh-CN'
    config.time_zone = 'Beijing'

    redis_conf = Settings['redis']
    config.cache_store = :redis_store, {
      host: redis_conf['host'],
      port: redis_conf['port'],
      db: redis_conf['cache_db'],
      password: redis_conf['password'],
      expires_in: 4.hours
    }

    config.eager_load_paths += [
      Rails.root.join('app/services')
    ]

    config.active_job.queue_adapter = :sidekiq

    config.api_only = true
  end
end