为什么我不能在Heroku上迁移我的rails项目的数据库?

时间:2013-10-31 12:29:24

标签: ruby-on-rails heroku rake pg

我在Heroku上有一个现有的rails(3.2.14)项目,需要迁移数据库。但是当我尝试运行时:

     heroku run rake db:migrate

我刚收到错误。当我们有R99错误(下面的heroku日志)时,这意味着一个平台问题。但heroku状态页面没有任何问题。这是我的--trace:

     $ heroku run rake db:migrate --trace
     Running `rake db:migrate --trace` attached to terminal... up, run.4543
     ** Invoke db:migrate (first_time)
     ** Invoke environment (first_time)
     ** Execute environment
     Connecting to database specified by DATABASE_URL
     rake aborted!
     SIGTERM
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:653:in `select'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:653:in `request'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:506:in `block in each_resource'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1023:in `block (3 levels) in          resolv'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1021:in `each'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1021:in `block (2 levels) in resolv'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1020:in `each'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1020:in `block in resolv'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1018:in `each'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:1018:in `resolv'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:498:in `each_resource'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:391:in `each_address'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:115:in `block in each_address'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:114:in `each'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:114:in `each_address'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:92:in `getaddress'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/resolv.rb:43:in `getaddress'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-         3.6.7.152/lib/new_relic/control/server_methods.rb:70:in `resolve_ip_address'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/control/server_methods.rb:59:in `convert_to_ip_address'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/control/server_methods.rb:45:in `server_from_host'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/control/server_methods.rb:19:in `server'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/agent/new_relic_service.rb:28:in `initialize'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/agent/agent.rb:39:in `new'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/agent/agent.rb:39:in `initialize'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/agent/agent.rb:70:in `new'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/agent/agent.rb:70:in `instance'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/new_relic/control/instance_methods.rb:75:in `init_plugin'
     /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.6.7.152/lib/newrelic_rpm.rb:40:in `block in <class:Railtie>'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `instance_exec'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `run'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/initializable.rb:55:in `block in run_initializers'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `each'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `run_initializers'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/application.rb:136:in `initialize!'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/railtie/configurable.rb:30:in `method_missing'
     /app/config/environment.rb:5:in `<top (required)>'
     /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
     /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
     /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
     /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/application.rb:103:in          `require_environment!'
     /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.14/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in          invoke_with_call_chain'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in          `invoke_with_call_chain'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
     /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
     /app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
     /app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `load'
     /app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `<main>'
     Tasks: TOP => db:migrate => environment

和heroku日志:

     2013-10-31T11:44:20+00:00 heroku[slug-compiler]: Slug compilation started
     2013-10-31T11:44:52.399896+00:00 heroku[api]: Deploy b311a8a by ex@gmail.com
     2013-10-31T11:44:52.588630+00:00 heroku[api]: Release v10 created by ex@gmail.com
     2013-10-31T11:44:52+00:00 heroku[slug-compiler]: Slug compilation finished
     2013-10-31T11:44:53.144455+00:00 heroku[web.1]: State changed from up to starting
     2013-10-31T11:44:55.603062+00:00 heroku[web.1]: Stopping all processes with SIGTERM
     2013-10-31T11:44:57.453462+00:00 heroku[web.1]: Process exited with status 0
     2013-10-31T11:45:00.188675+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RAILS_ENV -p 32970`
     2013-10-31T11:45:07.793567+00:00 app[web.1]: /app/bin/wkhtmltopdf-amd64
     2013-10-31T11:45:08.480104+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
     2013-10-31T11:45:09.700798+00:00 app[web.1]: >> Maximum connections set to 1024
     2013-10-31T11:45:09.700798+00:00 app[web.1]: >> Listening on 0.0.0.0:32970, CTRL+C to stop
     2013-10-31T11:45:09.700798+00:00 app[web.1]: >> Thin web server (v1.5.1 codename Straight Razor)
     2013-10-31T11:45:09.760592+00:00 heroku[web.1]: State changed from starting to up
     2013-10-31T11:45:43.023857+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by ex@gmail.com
     2013-10-31T11:45:47.706892+00:00 heroku[run.7727]: Awaiting client
     2013-10-31T11:45:55.105222+00:00 heroku[run.7727]: State changed from starting to up
     2013-10-31T11:45:57.322699+00:00 heroku[run.7727]: Error R99 (Platform error) -> Failed to launch the dyno within 10 seconds
     2013-10-31T11:45:57.323016+00:00 heroku[run.7727]: Stopping process with SIGKILL
     2013-10-31T11:45:57.368215+00:00 heroku[run.7727]: State changed from up to complete
     2013-10-31T11:46:04.657083+00:00 heroku[run.7727]: Starting process with command `bundle exec rake db:migrate`
     2013-10-31T11:48:08.633448+00:00 heroku[run.7727]: Stopping all processes with SIGTERM
     2013-10-31T11:48:18.781513+00:00 heroku[run.7727]: Stopping remaining processes with SIGKILL
     2013-10-31T11:48:18.781292+00:00 heroku[run.7727]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
     2013-10-31T11:48:19.712818+00:00 heroku[run.7727]: Client connection closed. Sending SIGHUP to all processes
     2013-10-31T11:48:21.005685+00:00 heroku[run.7727]: Process exited with status 137

1 个答案:

答案 0 :(得分:1)

heroku run命令在端口5000上打开与Heroku的连接。因此,问题出在我的新ISP中。端口5000正在阻塞。

Heroku docs:https://devcenter.heroku.com/articles/one-off-dynos#troubleshooting

另一个问题:Heroku run console get "Timeout awaiting process"