我在部署到Heroku时遇到了问题。一切都在我的开发机器上正常工作(我正在使用工头/独角兽来运行Web Worker和背景延迟过程)。但是,当我尝试在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>'

令人困惑的部分是,错误跟踪都是GEM代码...我的独角兽 / 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

事实证明,Heroku目前与Rails 3.2和自定义伐木相处融洽。

解决了我的问题是什么 - 评论以下内容:

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

也可以看看http://broadcastingadam.com/2012/01/rails320_heroku_and_rails_log_stdout

其他提示

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

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

  • 开始的香草舞台环境开始...
  • 一一添加Heroku服务并测试您的应用程序。

我曾经与遗物曾经有一个问题,一切都在开发和舞台上起作用,但是生产根本没有起作用。事实证明,由于某种原因,该版本的遗物与Rails的版本不兼容。

另外,关于您的问题,您正在使用什么Heroku堆栈?您是在雪松堆或竹子上跑步吗?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top