【问题标题】:Rails deployment in production - always complain about dalli生产中的 Rails 部署 - 总是抱怨 dalli
【发布时间】:2015-07-22 13:48:01
【问题描述】:

在尝试生产部署时使用我无法摆脱此错误

Could not find cache store adapter for mem_cache_store (cannot load such file -- dalli) (RuntimeError)

我真的不明白。到目前为止,我在开发中部署没有问题,即使我将副本 /environments/development.rb 更改为我的 Gemfile 中的 /environments/production.rb, I still get the same message. I have added the gemdelli`,但它仍然会抱怨。

我不知道这个mem_cache_store 来自哪里,因为即使我明确地将:memory_store 更改为:file_store,错误仍然存​​在

environments/production.rb

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_files = false
  config.assets.js_compressor = :uglifier
  config.assets.css_compressor = :sass
  config.assets.compile = false
  config.assets.digest = true
  config.assets.version = '1.0'
  config.force_ssl = true
  config.log_level = :debug
  ActionMailer::Base.smtp_settings = {
    :address => "localhost",
  }
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.cache_store = :memory_store
  config.log_formatter = ::Logger::Formatter.new
end

Capistrano 部署/production.rb

set :branch, :production
set :stage, :production
set :rails_env, 'production'
set :deploy_to, '/var/www/******'

set :log_level, :debug
set :keep_releases, 5
set :bundle_without, %w{test development}.join(' ') 
set :bundle_flags, '--deployment --quiet'

错误的全栈跟踪

Could not find cache store adapter for mem_cache_store (cannot load such file -- dalli) (RuntimeError)
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:106:in `rescue in retrieve_store_class'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:104:in `retrieve_store_class'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:60:in `lookup_store'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application/bootstrap.rb:76:in `block in <module:Bootstrap>'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/local/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  /usr/local/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  /usr/local/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:180:in `each'
  /usr/local/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
  /var/www/intranet_rails_test/releases/20150511202754/config/environment.rb:7:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `eval'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'

使用 Capistrano 3、Rails 4.2

【问题讨论】:

  • memcached 是否安装在您尝试部署到的服务器上?
  • 哦等等,它不只是一颗宝石吗?我需要在 debian 服务器上安装一些软件包吗?
  • 有些 gem 需要安装包。 Dalli 使用内存缓存。如果你需要 Dalli,你需要在服务器上安装 memcache 包
  • 谢谢,apt-get install 已修复!如果您添加答案,我会接受。

标签: ruby-on-rails ruby deployment production capistrano3


【解决方案1】:

有些 gem 需要安装包。 Dalli 使用 memcached。如果你需要 dalli,请使用你的包管理器来安装它(apt-get 等)

【讨论】:

    猜你喜欢
    • 2022-07-05
    • 2020-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多