我正在使用scheduler addon
from heroku 运行 rake 任务。它在开发中有效,但在生产中失败。这是heroku日志中的堆栈跟踪:
2012-10-10T23:30:23+00:00 heroku[api]:通过 scheduler@addons.heroku.com 使用命令 `bundle exec rake deal --trace` 启动进程 2012-10-10T23:30:29+00:00 heroku[scheduler.1]:使用命令“bundle exec rake deal--trace”启动进程 2012-10-10T23:30:30+00:00 heroku[scheduler.1]:状态从开始变为向上 2012-10-10T23:30:56+00:00 app[scheduler.1]:弃用警告:供应商/插件中有 Rails 2.3 风格的插件!Rails 4.0 将删除对这些插件的支持。将它们移出并将它们捆绑到您的 Gemfile 中,或者将它们作为 lib/myplugin/* 和 config/initializers/myplugin.rb 折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。(从 /app/Rakefile:7 调用) 2012-10-10T23:30:56+00:00 app[scheduler.1]:弃用警告:供应商/插件中有 Rails 2.3 风格的插件!Rails 4.0 将删除对这些插件的支持。将它们移出并将它们捆绑到您的 Gemfile 中,或者将它们作为 lib/myplugin/* 和 config/initializers/myplugin.rb 折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。(从 /app/Rakefile:7 调用) 2012-10-10T23:30:56+00:00 app[scheduler.1]: ** 调用交易 (first_time) 2012-10-10T23:30:56+00:00 app[scheduler.1]: ** 调用环境 (first_time) 2012-10-10T23:30:56+00:00 app[scheduler.1]: ** 调用文档:remove_documents (first_time) 2012-10-10T23:30:56+00:00 app[scheduler.1]: ** 执行环境 2012-10-10T23:31:00+00:00 app[scheduler.1]: ** 执行文档:remove_documents 2012-10-10T23:31:01+00:00 app[scheduler.1]: ** 调用环境 2012-10-10T23:31:01+00:00 app[scheduler.1]: ** 执行文档:add_documents 2012-10-10T23:31:01+00:00 app[scheduler.1]: ** 调用文档:add_documents (first_time) 2012-10-10T23:31:18+00:00 app[scheduler.1]: TypeError: can't dump anonymous class Class: INSERT INTO "documents" ("body", "created_at", "merchant_id", "updated_at ") 值 ($1, $2, $3, $4) 返回 "id" 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:6:in `to_yaml' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `each' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `call' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:rake 中止! 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :665:in `exec_query 中的块' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `map' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:16:in `block in to_yaml' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb :280:in `block in log' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :1168:in `exec_cache 中的块' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:17:in `block (2 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:119:in `dump' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `block (3 levels) in to_yaml ' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `emit' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/query_cache .rb:14:在“插入”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/relation.rb:66 :在“插入”中 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `add' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `call' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:15:in `to_yaml' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :1167:in `exec_cache' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/timestamp.rb:57 :在“创建”中 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :468:in `type_cast' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:403 :在`_run__2196213232156732911__create__4012089935340517551__callbacks' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385 :在`_run_create_callbacks' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:268 :在“创建”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `call' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/quoting .rb:74:in `type_cast' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb :20:在“仪器”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:264 :in `block in create_or_update' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385 :在`_run_save_callbacks' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:268 :in `block in create' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405 :in `__run_callback' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/usr/local/lib/ruby/1.9.1/syck.rb:401:in `quick_emit' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/syck/rubytypes.rb:18:in `node_export' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :663:在“exec_query”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements .rb:63:in `exec_insert' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements .rb:90:在“插入”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:264 :在`create_or_update' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405 :in `__run_callback' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81 :in `run_callbacks' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/validations.rb:50 :在“保存”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:366 :在“创建”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81 :in `run_callbacks' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb :1167:在“地图”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb :275:在“日志”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:347 :在`create_or_update' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:84 :在“保存”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:425 :在`_run__2196213232156732911__save__4012089935340517551__callbacks' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb :22:在“保存”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241 :in `block (2 levels) in save' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295 :in `block in with_transaction_returning_status' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements .rb:192:在“交易”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208 :在“交易”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293 :in `with_transaction_returning_status' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:241 :in `block in save' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:252 :in `rollback_active_record_state!' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/transactions.rb:240 :在“保存”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:45 :在“创建”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/app/models/worker.rb:54:in `block in add_documents' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/app/models/worker.rb:27:in `each' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/app/models/worker.rb:27:in `add_documents' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/lib/tasks/scrape.rake:9:in `block (2 levels) in ' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205 :在“通话”中 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205 :in `block in execute' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200 :在“每个”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200 :在“执行”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158 :in `block in invoke_with_call_chain' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174 :在“每个”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151 :in `invoke_with_call_chain' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176 :in `block in invoke_prerequisites' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174 :in `invoke_prerequisites' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151 :in `invoke_with_call_chain' 2012-10-10T23:31:18+00:00 应用程序 [scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157 :in `block in invoke_with_call_chain' 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144 :在“调用”中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116 :in `invoke_task' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94 :in `block (2 levels) in top_level' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94 :in `block in top_level' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94 :在“每个”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133 :在“标准异常处理”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88 :在`top_level'中 2012-10-10T23:31:18+00:00 app[scheduler.1]:/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66 :in `block in run' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133 :在“标准异常处理”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63 :在“运行”中 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `' 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load' 2012-10-10T23:31:18+00:00 app[scheduler.1]:任务:TOP => 交易 => 文档:add_documents 2012-10-10T23:31:18+00:00 app[scheduler.1]: /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `' 2012-10-10T23:31:20+00:00 heroku[scheduler.1]:进程以状态 1 退出 2012-10-10T23:31:20+00:00 heroku[scheduler.1]:状态从 up to complete
这是我试图插入数据库的模型方法:
def self.add_documents body = Nokogiri::HTML(open('http://www.someurl.com')).to_s.to_my_utf8 Merchant_id = Merchant.find(1) Document.create(:merchant_id => Merchant_id, :body => body) 结尾 # 配置/初始化程序/string.rb 需要'iconv' 类字符串 def to_my_utf8 ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', self + ' ')[0..-2] 结尾 结尾
我很想在这个问题上提供任何帮助!
编辑:更新了完整的堆栈跟踪。