1

我的数据库推送停止工作。

这是我的deploy.rb文件:https ://gist.github.com/a20d10a8a25c64c2d238

我正在使用'capistrano-db-tasks'. 如何调试问题出在哪里?

Are you sure you want to erase your local database with server database (y)es, (n)o  ? y
local {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"app-development", "username"=>"root", "password"=>nil, "host"=>"localhost", "port"=>3306}
  * executing "cat /home/app/current/config/database.yml"
    servers: ["213.238.59.107"]
    [213.238.59.107] executing command
    command finished in 345ms
/Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 1 column 14 (Psych::SyntaxError)
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
        from /Users/rege/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:64:in `initialize'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:122:in `new'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/database.rb:122:in `remote_to_local'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/dbtasks.rb:31:in `block (4 levels) in <top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-db-tasks-0.2/lib/capistrano-db-tasks/dbtasks.rb:38:in `block (3 levels) in <top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `each'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:34:in `execute!'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/lib/capistrano/cli/execute.rb:14:in `execute'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/gems/capistrano-2.15.4/bin/cap:4:in `<top (required)>'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/bin/cap:23:in `load'
        from /Users/rege/.rbenv/versions/2.0.0-p247/gemsets/app/bin/cap:23:in `<main>'
4

1 回答 1

0

问题在于capistrano-db-tasks您正在使用的 Gem。

显然,它读取的配置文件,一个 YAML 文件,显然是格式错误的。

Psych 是 Ruby ( https://github.com/tenderlove/psych )附带的 YAML 解析器,它无法读取您的文件。

这本身不是 Capistrano 问题。

可能您服务器上的文件/home/app/current/config/database.yml不可读。您可以尝试通过 YAML Lint ( http://yamllint.com/ )运行该文件以检查它是否有错误。

最近(在过去两年内,大约在 1.9 开始流行的时候)Ruby(又名 YARV、CRuby、MRI)从Ruby 2.0 YAML 页面切换了它的 YAML 解析器:

赛克¶ ↑</h3>

Syck 是 Ruby 标准库中 YAML 实现的原始版本,由为什么幸运的僵硬开发。

如果您愿意,您仍然可以通过如下更改来使用 Syck YAML::ENGINE

YAML::ENGINE.yamler = 'syck' # switch back to the default Psych YAML::ENGINE.yamler = 'psych'

我会确保您可以在(失败的)部署目录中的 rails 控制台上读取该文件,并联系capistrano-db-tasksgem 的供应商,它完全有可能在其他一些 YAML 文件上失败。

于 2013-10-23T12:32:05.407 回答