Heroku运行rake db:migrate时出现错误R13(附加错误)->无法附加到进程。

11

我有一个部署在Heroku上的Rails应用,但我无法使用最新的数据库更改。运行heroku run rake db:migrate会给我以下错误:

Running `rake db:migrate` attached to terminal... up, run.3167
!    Heroku client internal error.
!    Search for help at: https://help.heroku.com
!    Or report a bug at: https://github.com/heroku/heroku/issues/new

Error:       Operation timed out - connect(2) (Errno::ETIMEDOUT)
Backtrace:   /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `initialize'
             /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `open'
             /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `block in start'
             /usr/local/heroku/ruby/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
             /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:31:in `start'
             /Users/gregg/.heroku/client/lib/heroku/command/run.rb:132:in `rendezvous_session'
             /Users/gregg/.heroku/client/lib/heroku/command/run.rb:119:in `run_attached'
             /Users/gregg/.heroku/client/lib/heroku/command/run.rb:24:in `index'
             /Users/gregg/.heroku/client/lib/heroku/command.rb:218:in `run'
             /Users/gregg/.heroku/client/lib/heroku/cli.rb:28:in `start'
             /usr/bin/heroku:24:in `<main>'

Command:     heroku run rake db:migrate
Version:     heroku-toolbelt/3.2.1 (x86_64-darwin10.8.0) ruby/1.9.3

当我追踪日志时,我看到以下内容:

2014-01-04T20:27:56.438268+00:00 heroku[run.3167]: Awaiting client
2014-01-04T20:27:56.531495+00:00 heroku[run.3167]: State changed from starting to up
2014-01-04T20:26:58.751010+00:00 heroku[router]: at=info method=GETpath=/assets/SanukWebPro-Light.woff host=stormy-savannah-1911.herokuapp.com fwd="98.210.221.215" dyno=web.1 connect=6ms service=134ms status=200 bytes=38568
2014-01-04T20:27:11.027485+00:00 heroku[router]: at=info method=GET path=/articles/new host=stormy-savannah-1911.herokuapp.com fwd="98.210.221.215" dyno=web.1 connect=3ms service=54ms status=200 bytes=7577
2014-01-04T20:28:26.446139+00:00 heroku[run.3167]: Error R13 (Attach error) -> Failed to attach to process
2014-01-04T20:28:27.994826+00:00 heroku[run.3167]: Process exited with status 128
2014-01-04T20:28:28.005837+00:00 heroku[run.3167]: State changed from up to complete

你尝试了多少次?你是否稍作休息后又重新尝试了呢? - Mike Szyndel
2个回答

20

对我也有用,但您能否请解释为什么需要这样做? - BobDoolittle
错误的原因是:在运行 rake db:migrate attached to terminal 的过程中出错,提示为 Failed to attach to process。解决办法是以分离状态运行该命令。对于 2014-01-04T20:28:26.446139+00:00 heroku[run.3167]: Error R13 (Attach error) -> Failed to attach to process,暂时没有任何想法。 - Andrey Artemyev
2
我想了解为什么“run:detached”可以解决问题,以备将来参考。我知道它有效,但不知道为什么有效。 - BobDoolittle
4
run:detached 并没有完全解决问题,它只是不会尝试进行附加操作,因此不存在附加失败的情况。通常情况下,heroku run 意味着你的本地控制台将连接到一次性 dyno 上运行的命令,并且你可以看到其输出并进行交互(stdin、stdout、stderr 都已连接)。另一方面,heroku run:detached 不会连接你的本地控制台。你将无法进行交互操作(没有 stdin),只能检查日志以查看命令是否成功。 - Henrik Heimbuerger
我发现在我遇到这个问题的同时,我也超时了heroku run console。然而heroku maintenance:on是有效的。我怀疑(或者希望)这只是英雄开发者界面的暂时性问题。 - Obromios
显示剩余3条评论

1

运行后

    heroku run:detached rake db:migrate

我成功地运行了。
    heroku run rake db:migrate 

2
我猜这是因为它在分离运行时成功完成后,第二次调用它(不使用“分离”)不会执行任何操作 - 数据库已经设置好了。 - BobDoolittle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接