diff options
| author | mo <mo.khan@gmail.com> | 2017-09-24 12:56:20 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2017-09-24 12:56:20 -0600 |
| commit | a67e0cb103f76df6095257857e5f980340f3c940 (patch) | |
| tree | 7602d8e3f1c2bb721afaf4d891c1e3800c7166c6 /config | |
| parent | 96d66bcdb7bad43c3ec08349d2d978aec307ec90 (diff) | |
upgrade to rails 5.1
Diffstat (limited to 'config')
26 files changed, 267 insertions, 171 deletions
diff --git a/config/application.rb b/config/application.rb index b538d9c7..0bd93f2f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,54 +1,36 @@ -require File.expand_path("../boot", __FILE__) +require_relative 'boot' + +require "rails" +%w( + active_record/railtie + action_controller/railtie + action_view/railtie + action_mailer/railtie + active_job/railtie + action_cable/engine + active_storage/engine + sprockets/railtie +).each do |railtie| + begin + require railtie + rescue LoadError + end +end -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "sprockets/railtie" -# require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems -# you"ve limited to :test, :development, or :production. +# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Cake class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - - # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W(#{config.root}/app/services/application) config.autoload_paths += %W(#{config.root}/app/services/infrastructure) - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = "Central Time (US & Canada)" - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - translations_path = Rails.root.join("config", "locales", "**", "*.{rb,yml}") - config.i18n.load_path += Dir[translations_path] - # config.i18n.default_locale = :de - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - config.active_job.queue_adapter = :delayed_job - - config.middleware.use Rack::Cors do - allow do - origins "*" - resource "/api/v2/*", headers: :any, methods: [:get, :post, :put, :delete, :options] - resource "/api/v2/*/*", headers: :any, methods: [:get, :post, :put, :delete, :options] - end - end - config.middleware.use ExceptionNotification::Rack, email: { - email_prefix: "[Boom! #{Rails.env}] ", - sender_address: %{"notifier" <notifier@cakeside.com>}, - exception_recipients: ENV["EXCEPTION_EMAIL_ADDRESS"].try(:split, " "), - } unless Rails.env.test? - config.middleware.use Rack::Attack end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f00..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..841a323b --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 + channel_prefix: cake_production diff --git a/config/environment.rb b/config/environment.rb index 14dba1b1..426333bb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,7 +1,5 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) +# Load the Rails application. +require_relative 'application' -# Initialize the rails application +# Initialize the Rails application. Rails.application.initialize! -Date::DATE_FORMATS[:foomat] = "%d/%m/%Y" -Time::DATE_FORMATS[:foomat] = "%B. %d, %Y" diff --git a/config/environments/development.rb b/config/environments/development.rb index edae95cd..e643e6ea 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,55 +9,47 @@ Rails.application.configure do # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews" + config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: "localhost:3000" } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = false - - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = false - #config.assets.prefix = 'dev-assets' + config.assets.debug = true - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - config.action_mailer.default_url_options = { :host => "localhost:3000" } - config.action_mailer.smtp_settings = { - :address => ENV['SMTP_HOST'], - :port => ENV['SMTP_PORT'], - :domain => ENV['SMTP_DOMAIN'], - :user_name => ENV['SMTP_USERNAME'], - :password => ENV['SMTP_PASSWORD'], - :authentication => :plain, - :enable_starttls_auto => true - } - - config.after_initialize do - Bullet.enable = true - Bullet.alert = false - Bullet.bullet_logger = true - Bullet.console = true - Bullet.rails_logger = true - Bullet.add_footer = true - end + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index e298c0e0..20a54171 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -5,7 +5,7 @@ Rails.application.configure do config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers + # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true @@ -14,15 +14,14 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -31,48 +30,56 @@ Rails.application.configure do # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + config.action_controller.asset_host = ENV['ASSET_HOST'] + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. - config.log_level = :info + config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ lambda { |x| Time.now.utc }, :host, :remote_ip, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id, :host, :remote_ip ] # Use a different cache store in production. - config.cache_store = :mem_cache_store, 'localhost:11211' + config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - config.action_controller.asset_host = ENV['ASSET_HOST'] + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "cake_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + config.action_mailer.asset_host = ENV['ASSET_HOST'] + config.action_mailer.default_url_options = { host: 'www.cakeside.com' } + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV['SMTP_HOST'], + authentication: :plain, + domain: ENV['SMTP_DOMAIN'], + enable_starttls_auto: true, + password: ENV['SMTP_PASSWORD'], + port: ENV['SMTP_PORT'], + user_name: ENV['SMTP_USERNAME'], + } # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found). + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. @@ -81,22 +88,16 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - config.action_mailer.asset_host = ENV['ASSET_HOST'] - config.action_mailer.default_url_options = { :host => 'www.cakeside.com'} - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { - :address => ENV['SMTP_HOST'], - :port => ENV['SMTP_PORT'], - :domain => ENV['SMTP_DOMAIN'], - :user_name => ENV['SMTP_USERNAME'], - :password => ENV['SMTP_PASSWORD'], - :authentication => :plain, - :enable_starttls_auto => true - } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1adb7779..46501a97 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,11 +12,10 @@ Rails.application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=3600" + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" } # Show full error reports and disable caching. @@ -28,15 +27,13 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: 'www.example.com' } # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - config.action_mailer.default_url_options = { :host => 'www.blah.com'} - - # Randomize the order test cases are executed. - config.active_support.test_order = :random # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..89d2efab --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e66..4b828e80 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/bullet.rb b/config/initializers/bullet.rb new file mode 100644 index 00000000..652d10f1 --- /dev/null +++ b/config/initializers/bullet.rb @@ -0,0 +1,10 @@ +if Rails.env.development? + Rails.application.config.after_initialize do + Bullet.enable = true + Bullet.alert = false + Bullet.bullet_logger = true + Bullet.console = true + Bullet.rails_logger = true + Bullet.add_footer = true + end +end diff --git a/config/initializers/container.rb b/config/initializers/container.rb index c547bd79..69da6d59 100644 --- a/config/initializers/container.rb +++ b/config/initializers/container.rb @@ -21,7 +21,7 @@ if Rails.configuration.cache_classes ConfigureContainerCommand.new.configure(container) Spank::IOC.bind_to(container) else - ActionDispatch::Reloader.to_prepare do + ActiveSupport::Reloader.to_prepare do container = Spank::Container.new ConfigureContainerCommand.new.configure(container) Spank::IOC.bind_to(container) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458d..5a6a32d3 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb index dc12618c..d71d0024 100644 --- a/config/initializers/delayed_job_config.rb +++ b/config/initializers/delayed_job_config.rb @@ -1,3 +1,4 @@ +Rails.application.config.active_job.queue_adapter = :delayed_job Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 5 Delayed::Worker.max_attempts = 3 diff --git a/config/initializers/exception_notification.rb b/config/initializers/exception_notification.rb new file mode 100644 index 00000000..2f60458f --- /dev/null +++ b/config/initializers/exception_notification.rb @@ -0,0 +1,5 @@ +Rails.application.config.middleware.use ExceptionNotification::Rack, email: { + email_prefix: "[Boom! #{Rails.env}] ", + sender_address: %{"notifier" <notifier@cakeside.com>}, + exception_recipients: ENV["EXCEPTION_EMAIL_ADDRESS"].try(:split, " "), +} unless Rails.env.test? diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 00000000..9010abd5 --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 624c8996..a4631e88 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -1,3 +1,4 @@ +Rails.application.config.middleware.use Rack::Attack # Always allow requests from localhost # (blacklist & throttles are skipped) Rack::Attack.safelist('allow from localhost') do |request| diff --git a/config/initializers/rack_cors.rb b/config/initializers/rack_cors.rb new file mode 100644 index 00000000..6c8b8499 --- /dev/null +++ b/config/initializers/rack_cors.rb @@ -0,0 +1,7 @@ +Rails.application.config.middleware.use Rack::Cors do + allow do + origins "*" + resource "/api/v2/*", headers: :any, methods: [:get, :post, :put, :delete, :options] + resource "/api/v2/*/*", headers: :any, methods: [:get, :post, :put, :delete, :options] + end +end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 0f5a3c71..470a569a 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. configuration = { key: "_cake_eater_#{Rails.env}", - expire_after: 2.weeks, + expire_after: 20.minutes, secure: Rails.env.production? } Rails.application.config.session_store :cookie_store, configuration diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95..bbfc3961 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/config/locales/controllers/my/passwords/en.yml b/config/locales/controllers/my/passwords/en.yml deleted file mode 100644 index 60d898e6..00000000 --- a/config/locales/controllers/my/passwords/en.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -en: - my: - passwords: - passwords_do_not_match: The passwords should match and should be a minimum of 6 characters. - updated: Your password was updated. diff --git a/config/locales/controllers/passwords/en.yml b/config/locales/controllers/passwords/en.yml deleted file mode 100644 index 28a1c00d..00000000 --- a/config/locales/controllers/passwords/en.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -en: - passwords: - send_instructions: You will receive an email with instructions about how to reset your password in a few minutes. diff --git a/config/locales/controllers/sessions/en.yml b/config/locales/controllers/sessions/en.yml deleted file mode 100644 index cc868578..00000000 --- a/config/locales/controllers/sessions/en.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -en: - sessions: - new: - sign_in: "Sign In" - create: - failure: - invalid: Invalid email or password. diff --git a/config/locales/en.yml b/config/locales/en.yml index 3ea4c436..6759fce6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,8 +1,23 @@ --- en: + activerecord: + attributes: + search: + q: "Search query" + session: + email: 'Email' + password: 'Password' + user: + accepted: "Terms and conditions" + email: 'Email' + name: 'Full name' + password: 'Password' avatar_uploaded: Your avatar has been updated. logout: Sign Out my: + passwords: + passwords_do_not_match: The passwords should match and should be a minimum of 6 characters. + updated: Your password was updated. shared: my_nav: activity: "Activity" @@ -19,16 +34,12 @@ en: products: "Products" sessions: "Sessions" users: "Users" + passwords: + send_instructions: You will receive an email with instructions about how to reset your password in a few minutes. profile_saved: Your settings have been updated successfully! - activerecord: - attributes: - search: - q: "Search query" - session: - email: 'Email' - password: 'Password' - user: - accepted: "Terms and conditions" - email: 'Email' - name: 'Full name' - password: 'Password' + sessions: + new: + sign_in: "Sign In" + create: + failure: + invalid: Invalid email or password. diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 00000000..1e19380d --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/secrets.yml b/config/secrets.yml index db9c61e5..0405307e 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -5,18 +5,28 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. +# You can use `rails secret` to generate a secure secret key. # Make sure the secrets in this file are kept private # if you're sharing your code publicly. +# Shared secrets are available across all environments. + +# shared: +# api_key: a1B2c3D4e5F6 + +# Environmental secrets are only available for that specific environment. + development: - secret_key_base: 5a8d8856ac7ff89a031cc8370020c03f48be94e1d52a2ad02848bd27b1e8864f6c87626203b464b53d6ab9ed1c0e63d068b4b13a9998eb67105b1c2a5df071c3 + secret_key_base: 1ed924a41f8dc3278c0bd50d973ede2f696cd4de4d200d1a0edd4409e54b2658c0fd1fe432ac69759bf4280a231b67533538f0900c084362f545215e0761435a test: - secret_key_base: a275a537c6ab6aedf787c652911b1f6d4ba733f12d07df51e5d1bebc134cef1bf750462cd338493d08c305a8764e3889f73e218e9f83d5add377b0282dd959e4 + secret_key_base: ebd8beba60c7889855b12837af2020e396d06d720fc467b7e840ce23e00769504af77a67ae0d88d58c294b9fccf6677a7865f05383417cae8894d5e705b6cdea + +# Do not keep production secrets in the unencrypted secrets file. +# Instead, either read values from the environment. +# Or, use `bin/rails secrets:setup` to configure encrypted secrets +# and move the `production:` environment over there. -# Do not keep production secrets in the repository, -# instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 00000000..c9119b40 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } |
