【问题标题】:Rails Gemfile.lockRails Gemfile.lock
【发布时间】:2014-03-08 18:11:53
【问题描述】:

我在Gemfile 中添加了一个开发部分

group :development do
    gem 'thin'
end

然后在我的本地机器上运行bundle install。这创建了一个包含薄的Gemfile.lock。我将此文件签入到 repo 并推送到 Heroku。通常我在生产中使用unicorn 服务器。但是当这个版本的 Gemfile 被推送到 Heroku 时,应用程序崩溃了,提示 command thin not found

我不明白为什么只包含在开发组中的 gem 会影响我的生产部署。什么是仅在开发中包含 gem 而不会影响 Heroku 生产部署的正确方法?

【问题讨论】:

  • 您确定您的 Heroku 应用程序正在生产模式下运行吗?运行heroku config 来检查环境变量。 RACK_ENVRAILS_ENV 应该是生产环境。
  • heroku config 表示 RAILS_ENVRACK_ENV 设置为 staging。这是我的暂存环境,带有一个用于配置的 staging.rb 文件。

标签: ruby-on-rails ruby-on-rails-3 heroku gemfile gemfile.lock


【解决方案1】:

我在 heroku 上使用 unicorn 并在开发时使用 Thin。我的 unicorn 和 thin 包含在 gemfile 的顶部(thin 不在开发中),它们工作正常。检查您的 unicorn.rb(我的如下)并更新您的 gemfile。

worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true

before_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

【讨论】:

    猜你喜欢
    • 2012-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多