簡體   English   中英

Unicorn Deploy to Heroku的問題-僅生產環境問題

[英]Issue with Unicorn Deploy to Heroku - production environment issues only

我在部署到Heroku時遇到問題。 一切在我的開發機器上都可以正常工作(我正在使用Foreman / Unicorn運行Web工作者和后台DelayedJob進程)。 但是,當我嘗試在Heroku上的Production中運行時,出現關於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

程序:

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

我可以發布任何其他有用的信息!!! 提前致謝...

我不能代表您的開發問題,因此,這不僅僅是建議,還是答案(但比答案需要更多的空間)。

過去,我在生產環境中遇到過Heroku和服務/寶石方面的問題。 我建議您要做的是在Heroku上創建一個暫存環境並在其中測試您的代碼。 但是,您應該以兩種方式對其進行測試:

  • 最初的香草分期環境...
  • 逐一添加heroku服務並測試您的應用程序。

我曾經在Relic遇到過一個問題,那就是一切都可以在Dev和Staging中使用,但是生產根本無法正常工作。 事實證明,由於某種原因,該遺物的版本與Rails的版本不兼容。

另外,關於您的問題,您正在運行什么Heroku堆棧? 您是在Cedar堆棧還是Bamboo上運行?

事實證明,Heroku當前與Rails 3.2和自定義日志記錄的關系不佳。

解決了我的問題的原因-注釋掉以下內容:

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

另請參見http://broadcastingadam.com/2012/01/rails320_heroku_and_rails_log_stdout

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM