【问题标题】:cap deploy upload via sftp failed上限部署通过 sftp 上传失败
【发布时间】:2012-11-13 18:29:18
【问题描述】:

美好的一天!我会尽量具体说明这一点。很抱歉,我在尝试部署我的应用程序时遇到了很多麻烦。我对 Rails 完全陌生,所以我遵循了使用 Rails 第 4 版进行敏捷 Web 开发,我被困在使用 capistrano 部署的部分我已经尝试了书中的确切代码,没有工作,并采取了一些来自这个论坛和其他论坛的建议被证明是有帮助的,但我仍然无法正确部署我的 deploy.rb 是这样的:

require 'bundler/capistrano'

set :user, 'user_created_for_this_example'

set :domain,  'IPADDRESS'

set :application, 'depot'

# file paths

set :repository,  "#{user}@#{domain}:depot.git"

set :deploy_to, "/home/#{user}/#{domain}"

# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess 
based on known version control directory names

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

#roles server

role :web, domain

role :app, domain

role :db, domain, :primary => true

#deploy config

set :deploy_to, "/home/#{user}/#{domain}"

set :deploy_via, :copy

set :scm, 'git'

set :branch, 'master'

set :scm_verbose, true

set :use_sudo, false 


# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:

namespace :deploy do

  task :start do ; end

  task :stop do ; end

  task :restart, :roles => :app, :except => { :no_release => true } do

    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"

  end

end

after "deploy:update_code", :bundle_install

desc "install the necesary prerequisites"

task :bundle_install, :roles => :app do

  run "cd #{release_path} && bundle install"

end

当我运行 cap deploy:setup 和 cap deploy:check all 似乎工作正常:

~/rails_projects/depot$ cap deploy:setup

  * 2012-11-13 10:37:35 executing `deploy:setup'

  * executing "mkdir -p /home/git/xx.xx.xx.xx /home/git/xx.xx.xx.xx/releases /home/git
/xx.xx.xx.xx/shared /home/git/xx.xx.xx.xx/shared/system /home/git/xx.xx.xx.xx/shared/log 
/home/git/xx.xx.xx.xx/shared/pids"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 158ms

  * executing "chmod g+w /home/git/xx.xx.xx.xx /home/git/xx.xx.xx.xx/releases /home/git/xx.xx.xx.xx/shared /home/git/xx.xx.xx.xx/shared/system /home/git/xx.xx.xx.xx/shared/log /home/git/xx.xx.xx.xx/shared/pids"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 7ms

~/rails_projects/depot$ cap deploy:check

  * 2012-11-13 10:37:39 executing `deploy:check'

  * executing "test -d /home/git/xx.xx.xx.xx/releases"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 152ms

  * executing "test -w /home/git/xx.xx.xx.xx"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 5ms

  * executing "test -w /home/git/xx.xx.xx.xx/releases"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 5ms

  * executing "which tar"

    servers: ["xx.xx.xx.xx"]

    [xx.xx.xx.xx] executing command

    command finished in 6ms

You appear to have all necessary dependencies installed

但是当 cap deploy:migrations、cap deploy 或 cap deploy:cold 命令出现时会弹出下一个:

~/rails_projects/depot$ cap deploy:migrations

  * 2012-11-13 10:37:42 executing `deploy:migrations'

  * 2012-11-13 10:37:42 executing `deploy:update_code'

    executing locally: "git ls-remote git@xx.xx.xx.xx:depot.git master"

    command finished in 241ms

  * getting (via checkout) revision c3f88ca97e5868dd476f20e9a044b7dad800274a to /tmp/20121113173743

    executing locally: git clone git@xx.xx.xx.xx:depot.git /tmp/20121113173743 && cd /tmp/20121113173743 && git checkout -b deploy c3f8
8ca97e5868dd476f20e9a044b7dad800274a

Cloning into '/tmp/20121113173743'...

remote: Counting objects: 392, done.

remote: Compressing objects: 100% (257/257), done.

remote: Total 392 (delta 111), reused 392 (delta 111)

Receiving objects: 100% (392/392), 8.59 MiB, done.

Resolving deltas: 100% (111/111), done.

Switched to a new branch 'deploy'

    command finished in 769ms

  * Compressing /tmp/20121113173743 to /tmp/20121113173743.tar.gz

    executing locally: tar czf 20121113173743.tar.gz 20121113173743

    command finished in 652ms

    servers: ["xx.xx.xx.xx"]

 ** sftp upload /tmp/20121113173743.tar.gz -> /tmp/20121113173743.tar.gz

    [xx.xx.xx.xx] /tmp/20121113173743.tar.gz

*** upload via sftp failed on xx.xx.xx.xx: Net::SFTP::StatusException 
(Net::SFTP::StatusException open /tmp/20121113173743.tar.gz (3, "permission denied"))

upload via sftp failed on xx.xx.xx.xx: Net::SFTP::StatusException (Net::SFTP::StatusException open /tmp/20121113173743.tar.gz (3, "permission denied"))

很抱歉,如果这是一些虚拟问题、易于修复的问题或已经发布的问题,但我不知道还能尝试什么,再次,我只是从这些东西开始,我真的迷路了.我在同一台机器上运行所有东西,所有 xx.xx.xx.xx 代表我的 IP 地址。任何建议将不胜感激。我试图尽可能具体,但如果缺少某些内容,我会发布它。预先感谢您的时间和帮助。

【问题讨论】:

  • permission denied: 权限不足?你可以手动访问你的FTP并在/home/user/etc写东西吗?
  • 我认为问题出在您的 FTP 配置中。
  • 遇到了同样的问题并解决了。使用 ls -al / 您可以查看 tmp 文件夹的创建者是哪个组。使用命令 id、groups 和 usermod,您必须将自己添加到创建者组中。
  • 这是一个老问题,但如果您仍有疑问,本指南可能会有所帮助:help.github.com/articles/deploying-with-capistrano

标签: ruby-on-rails capistrano web-deployment


【解决方案1】:

您的问题是您的 sftp 源和目标位置相同:

** sftp upload /tmp/20121113173743.tar.gz -> /tmp/20121113173743.tar.gz

为了解决这个问题,您可以在 config/deploy.rb 文件中指定参数 copy_dir,如下所示:

set :copy_dir, "/tmp/sftp"

那时不需要手动创建该文件夹。

【讨论】:

  • 感谢您对我的帮助。现在显示: sftp upload /tmp/sftp/20160202184928.tar.gz -> /tmp/20160202184928.tar.gz 没有更多错误
【解决方案2】:

尝试将此行添加到您的 deploy.rb 配置文件中:

default_run_options[:pty] = true

【讨论】:

  • 谢谢达里奥!但结果还是一样,我也读过关于添加 ssh_options[:forward_agent] = true 的内容,没有不同的结果。我确实认为问题出在权限上,但我不知道如何解决这个问题。再次感谢您的回答和时间,任何建议都会被采纳,给您带来的麻烦深表歉意。
【解决方案3】:

我们将 Capfile 更改为

set :deploy_via, :copy

set :deploy_via, :remote_cache

这对我们有用。我们没有添加以下行

default_run_options[:pty] = true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 2013-11-17
    • 1970-01-01
    • 2017-12-16
    相关资源
    最近更新 更多