2013-05-15 147 views
1

由於我已經將我的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上設置?

非常感謝!

回答

3

最好的解決方案取決於你如何運行你的rake任務。例如,如果您是通過cronjob運行此操作,那麼您可以將NEWRELIC_ENABLE=false添加到您的rake任務的cron條目中。

否則,如果您正在手動運行您的rake任務,則應將以下內容添加到您的newrelic.yml文件中。

autostart.blacklisted_executables: rake

這將防止代理人在可執行文件叫耙任何情況下啓動。請注意,如果您有其他可執行文件,希望阻止New Relic啓動,則也可以使用逗號分隔列表。

+0

非常感謝Steven。我正在使用cronjobs,並且我正在尋求避免將NEWRELIC_ENABLE = false添加到每個條目(未來可能會非常棘手)。所以文件newrelic.yml的行是完美的! – dolarsrg

相關問題