由於我已經將我的Heroku應用程序中的newrelic_rpm gem從3.5.8.72更新爲3.6.1.88,我注意到newrelic正在加載我的耙子任務,給我奇怪的錯誤:newrelic_rpm:未定義的方法`before_save'for#<Class:0x00000004a28b28>
rake aborted!
undefined method `before_save' for #<Class:0x00000003d2f908>
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:90:in `<class:Session>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:79:in `<class:SessionStore>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:53:in `<module:ActiveRecord>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:3:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/configuration.rb:138:in `session_store'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:273:in `block in default_middleware_stack'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:237:in `tap'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:237:in `default_middleware_stack'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:469:in `app'
...
我知道這個問題來自newrelic_rpm肯定的,所以我不知道如何可以禁用它在耙任務莫名其妙。
我試着用https://newrelic.com/docs/ruby/forcing-the-ruby-agent-to-start設置一個ENV變量,但是它也會禁用webapp的newrelic。有沒有辦法爲我的所有rake任務設置ENV var,但只能在rake上設置,而不能在webserver上設置?
非常感謝!
非常感謝Steven。我正在使用cronjobs,並且我正在尋求避免將NEWRELIC_ENABLE = false添加到每個條目(未來可能會非常棘手)。所以文件newrelic.yml的行是完美的! – dolarsrg