Rails 5.1.3 アプリケーションを Pivotal Web Services で実行しています。Rails 4 からのアップグレード以降、アプリケーションは次のように動作します。
- 展開は正常に実行されます
- プーマが始まります
- 重要なコンテナは健全です
- 接続する最初のクライアントは、最初のページが表示されるまで 2 ~ 3 分間待機します。この期間中、サーバーは最大 100% の CPU を使用しています
これは、新しいインスタンスがインスタンス化されているときにも発生します。
「eager loading」設定を true と false の両方に変更しようとしましたが、動作に変化は見られませんでした。
config.eager_load = true
私はrack-cors gemの有無にかかわらずテストしましたが、変更もありません。
これが私のconfig/application.rbです:
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'pdfkit'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module MyFaro
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.
# 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 = 'Brussels'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
#config.i18n.load_path = Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :nl
#config.skylight.probes += %w(mongoid mongo)
config.middleware.use PDFKit::Middleware, {:print_media_type => true}, :only => %r[/print_story]
config.after_initialize do
ApplicationController.helpers.cache_set_look_up_hash
ApplicationController.helpers.cache_set_system_parameter_hash
end
end
end
そして私のconfig/environments/production.rb:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
#CORS
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# 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
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.cache_store = :memory_store
# 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.public_file_server.enabled = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass