Unicorn Deploy到Heroku的问题 - 仅限生产环境问题

时间:2012-02-16 02:21:37

标签: ruby-on-rails deployment heroku production-environment unicorn

我在部署到Heroku时遇到了问题。在我的开发机器上一切正常(我使用Foreman / Unicorn运行web worker和后台DelayedJob进程)。但是当我尝试在Heroku上运行时,我得到了关于logger的奇怪错误......

app error: undefined method `tagged' for #<Logger:0x00000005aee368> (NoMethodError)
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:14:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:132:in `forward'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:241:in `fetch'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:181:in `lookup'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:65:in `call!'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:50:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:530:in `process_client'
/app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:604:in `worker_loop'
/app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:487:in `spawn_missing_workers'
/app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:137:in `start'
/app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.2.0/bin/unicorn:121:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/unicorn:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/unicorn:19:in `<main>'

令人困惑的部分是错误跟踪是所有宝石代码...我的unicorn / proc文件可能有问题?

独角兽:

worker_processes 3 # amount of unicorn workers to spin up
preload_app true
timeout 30         # restarts workers that hang for 30 seconds

@delayedjob_pid = nil

before_fork do |server, worker|
  @delayedjob_pid ||= spawn("bundle exec rake environment jobs:work QUEUE=immediate")
end

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

PROC:

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

我可以发布任何其他有用的东西!提前谢谢......

2 个答案:

答案 0 :(得分:0)

我不能代表您的发展问题,所以这更像是一个建议而不是答案(但它需要的空间比答案多一点)。

过去我在生产环境中遇到过Heroku和服务/宝石的问题。我建议你做的是在Heroku上创建一个临时环境并在那里测试你的代码。但是,您应该以两种方式测试它:

  • 一个香草分期环境,然后开始......
  • 逐个添加heroku服务并测试您的应用程序。

我曾经遇到过Relic的问题,其中一切都在Dev和Staging中有效,但是生产根本不起作用。原来那个版本的遗物由于某种原因与Rails的版本不兼容。

另外,关于你的问题,你在运行什么Heroku堆栈?你在Cedar堆栈或Bamboo上运行吗?

答案 1 :(得分:0)

事实证明,Heroku目前与Rails 3.2和自定义日志记录不相容。

解决了我的问题 - 注释出以下内容:

 #config.log_tags = [:uuid, :remote_ip]

另见 http://broadcastingadam.com/2012/01/rails320_heroku_and_rails_log_stdout