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

发布于 2024-12-15 16:49:37 字数 1978 浏览 3 评论 0原文

我在使用 Moonshine 和 Capistrano 设置新服务器时遇到问题。它似乎开始得很好,安装了一堆 Ubuntu 软件包,编译了 REE,安装了一些 gem,但随后它无法通过 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/生产.rb:

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

set :rails_env, 'production'

编辑2:我尝试使用SCP而不是SFTP,但没有走得更好。我将其添加到我的部署/生产.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 ())

I'm having trouble setting up a new server using Moonshine and Capistrano. It seems to get started pretty well, installs a bunch of Ubuntu packages, compiles REE, installs some gems, but then it fails to upload a file via SFTP with this output:

  * 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'

Googling that error isn't really turning much up, all I can figure out is that capistrano/transfer.rb is expecting something other than a PathName object on line 196, but I'm not sure what it's expecting, nor am I sure why it's being fed a PathName object.


Edit: Here is my 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'

... and my deploy/production.rb:

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

set :rails_env, 'production'

Edit 2: I tried using SCP instead of SFTP, but that didn't go any better. I added this to my deploy/production.rb:

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

and got this error instead while trying to deploy:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一曲爱恨情仇 2024-12-22 16:49:37

我也无法弄清楚该错误。您使用的 Capistrano 版本似乎已经过时一年多了。我会将您使用的版本更新为更新版本,然后重试。

如果这仍然不能解决您的问题,那么如果您提供了经过清理的deploy.rb配置副本,将会有所帮助。

I can't figure that error out either. It appears the version of Capistrano your using is fairly outdated by a year plus. I would update the version your using to a more recent release, and try again.

If that still doesn't resolve your problem it would help if you provided sanitized copy of your deploy.rb configuration.

猥︴琐丶欲为 2024-12-22 16:49:37

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

以下是我解决这个问题的方法:

  • 删除 config/moonshine/production.yml (将 product 替换为您的部署阶段的名称)
  • 运行 cap production deploy:setup< /code>
  • config/moonshine/Production.yml 放回
  • 然后运行 ​​cap production deploy

Turns out that this was due to Moonshine not being able to handle the presence of deploy-stage-specific files (eg config/moonshine/production.yml) during cap production deploy:setup.

Here's how I got around it:

  • Remove config/moonshine/production.yml (replace production with whatever your deploy stage is called)
  • Run cap production deploy:setup
  • Put config/moonshine/production.yml back
  • Then run cap production deploy
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文