Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Heroku newrelic_rpm:未定义的方法`保存之前';对于#<;类别:0x00000004a28b28>;_Heroku_Rake_Newrelic - Fatal编程技术网

Heroku newrelic_rpm:未定义的方法`保存之前';对于#<;类别:0x00000004a28b28>;

Heroku newrelic_rpm:未定义的方法`保存之前';对于#<;类别:0x00000004a28b28>;,heroku,rake,newrelic,Heroku,Rake,Newrelic,自从我在Heroku应用程序上将newrelic_rpm gem从3.5.8.72更新到3.6.1.88后,我注意到newrelic正在我的rake任务中加载,给了我奇怪的错误: rake aborted! undefined method `before_save' for #<Class:0x00000003d2f908> /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynami

自从我在Heroku应用程序上将newrelic_rpm gem从3.5.8.72更新到3.6.1.88后,我注意到newrelic正在我的rake任务中加载,给了我奇怪的错误:

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'
...
rake中止!
未定义的“保存前”方法#
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active\u record/dynamic\u matchers.rb:55:in'method\u missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active\u record/session\u store.rb:90:in`'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active\u record/session\u store.rb:79:in`'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active\u record/session\u store.rb:53:in`'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active\u record/session\u store.rb:3:in`'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/configuration.rb:138:在“会话商店”中
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:273:in`block in default\u middleware\u 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\u middleware\u stack'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:469:in'app'
...
我知道问题肯定来自newrelic_rpm,所以我想知道如何在rake任务中禁用它

我尝试设置一个ENV变量,但它也会为webapp禁用newrelic。有没有一种方法可以为我所有的rake任务设置ENV var,但只能在rake上设置,而不能在web服务器上设置


非常感谢

最佳解决方案取决于您如何运行rake任务。例如,如果您是从cronjob运行此命令,那么您可以将
NEWRELIC\u ENABLE=false
预先添加到rake任务的cron条目中

否则,如果手动运行rake任务,则应将以下内容添加到newrelic.yml文件中

autostart.blacklist_可执行文件:rake


这将防止代理在可执行文件名为rake的任何实例中启动。请注意,如果您有其他可执行文件希望阻止New Relic在其中启动,则此列表也可以是逗号分隔的列表。

非常感谢。我正在使用cronjobs,我希望避免在每个条目中添加NEWRELIC_ENABLE=false(将来可能会很棘手)。因此,文件newrelic.yml的行是完美的!