为什么Moonshine / Capistrano在部署期间遇到SFTP问题:设置?

时间:2011-11-12 13:56:13

标签: ruby-on-rails capistrano

我在使用Moonshine和Capistrano设置新服务器时遇到问题。它似乎开始很好,安装了一堆Ubuntu软件包,编译REE,安装了一些宝石,但是它无法通过SFTP上传文件并输出:

  * executing `moonshine:setup_directories'
  * executing "mkdir /tmp/moonshine"
    servers: ["myserver.tld"]
    [myserver.tld] executing command
    command finished
    servers: ["myserver.tld"]
 ** sftp upload /Users/arussell/Sites/mysite/config/moonshine/production.yml -> /tmp/moonshine/production.yml
/Users/arussell/.rvm/gems/ree-1.8.7-2011.03/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:196:in `normalize': undefined method `pos' for #<Pathname:0x10f3a6988> (NoMethodError)
    from /Users/arussell/.rvm/gems/ree-1.8.7-2011.03/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:104:in `prepare_transfers'

谷歌搜索该错误并没有真正发生太大的变化,我所能想到的是,capistrano / transfer.rb期待第196行上的PathName对象以外的其他东西,但我不确定它的期望是什么,也不是我确定为什么它被提供一个PathName对象。


编辑:这是我的deploy.rb:

set :stages, %w(staging production dev)
set :default_stage, "staging"
require 'capistrano/ext/multistage' rescue "YOU NEED TO INSTALL THE capistrano-ext GEM"
require 'fileutils'

if ENV['branch']
  set :branch, ENV['branch']
end

set :deploy_via, :remote_cache

before "deploy:restart", "deploy:delete_cache"

namespace(:deploy) do
  desc "delete cache"
  task :delete_cache do
    run "rm -rf /usr/local/shared/cache/"
  end
  task :null, :roles => :app do
    run "date"
  end
end
require './config/boot'

...和我的deploy / production.rb:

server "myserver.tld", :app, :web, :db, :primary => true

set :rails_env, 'production'

编辑2:我尝试使用SCP代替SFTP,但这并没有改善。我将此添加到我的deploy / production.rb:

upload "local", "remote", :via => :scp
download "remote", "local", :via => :scp

并在尝试部署时遇到此错误:

upload via scp failed on myserver.tld: SCP did not finish successfully () (SCP did not finish successfully ())

2 个答案:

答案 0 :(得分:0)

我也无法想出那个错误。看来你使用的Capistrano版本已经过时了一年。我会将您使用的版本更新到更新版本,然后重试。

如果仍然无法解决您的问题,那么在您提供deploy.rb配置的清理副本时会有所帮助。

答案 1 :(得分:0)

事实证明,这是由于Moonshine无法在config/moonshine/production.yml期间处理特定于部署阶段的文件(例如cap production deploy:setup)。

以下是我如何解决这个问题:

  • 删除config/moonshine/production.yml(将production替换为您调用的部署阶段)
  • 运行cap production deploy:setup
  • 放回config/moonshine/production.yml
  • 然后运行cap production deploy