-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathapplication.rb
54 lines (43 loc) · 2.11 KB
/
application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require_relative 'boot'
require 'rails/all'
require 'sidekiq/web'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module BaseApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Log to STDOUT. You could then collect logs using journald, syslog or forward them somewhere else.
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
# Set Redis as the back-end for the cache.
config.cache_store = :redis_cache_store, {
url: ENV.fetch('REDIS_URL') { 'redis://redis:6379/1' },
namespace: 'cache'
}
# Set Sidekiq as the back-end for Active Job.
config.active_job.queue_adapter = :sidekiq
# Mount Action Cable outside the main process or domain.
config.action_cable.mount_path = nil
config.action_cable.url = ENV.fetch('ACTION_CABLE_FRONTEND_URL') { 'ws://localhost:28080' }
# Only allow connections to Action Cable from these domains.
origins = ENV.fetch('ACTION_CABLE_ALLOWED_REQUEST_ORIGINS') { "http:\/\/localhost*" }.split(',')
origins.map! { |url| /#{url}/ }
config.action_cable.allowed_request_origins = origins
# Protect sidekiq-web
Sidekiq::Web.use(Rack::Auth::Basic) do |username, password|
ActiveSupport::SecurityUtils.secure_compare(username, ENV.fetch('SIDEKIQ_WEB_USERNAME', 'sidekiq-web-dashboard')) &&
ActiveSupport::SecurityUtils.secure_compare(password, ENV.fetch('SIDEKIQ_WEB_PASSWORD', 'sidekiq-web-123'))
end
config.action_mailer.default_url_options = { host: ENV['DEFAULT_HOST'] }
end
end