cap развертывание загрузки через sftp не удалось

Добрый день! Я постараюсь уточнить это. Извините, но у меня было много проблем при попытке развернуть приложение. Я совершенно новичок в рельсах, поэтому я следил за Agile Web Development с Rails 4th Edition, и я застрял в сегменте развертывания с 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, все вроде работает нормально:

~/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 [email protected]:depot.git master"

    command finished in 241ms

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

    executing locally: git clone [email protected]: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-адрес. Мы будем очень благодарны за любые предложения. Я старался быть конкретным, но если чего-то не хватает, я отправлю это. Заранее спасибо за ваше время и помощь.


person Jorge    schedule 13.11.2012    source источник
comment
permission denied: Недостаточные разрешения? Можете ли вы получить доступ к FTP вручную и написать что-нибудь на /home/user/etc?   -  person caarlos0    schedule 13.11.2012
comment
Я действительно считаю, что проблема в вашей конфигурации FTP.   -  person caarlos0    schedule 14.11.2012
comment
была такая же проблема, и решите ее. С помощью ls -al / вы можете увидеть, какая группа является создателем папки tmp. С командами id, groups и usermod вы должны добавить себя в группу создателей.   -  person Prcela    schedule 21.02.2013
comment
Это старый вопрос, но это руководство может помочь, если вам все еще интересно: help.github .com / article / deploying-with-capistrano.   -  person Archonic    schedule 02.07.2013


Ответы (3)


Ваша проблема здесь в том, что ваши исходные и конечные местоположения для sftp совпадают:

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

чтобы решить эту проблему, вы можете указать параметр copy_dir в файле config / deploy.rb, примерно так:

set :copy_dir, "/tmp/sftp"

Тогда нет необходимости создавать эту папку вручную.

person Сергій Василенко    schedule 03.12.2014
comment
Спасибо, это помогло мне. Теперь показывает: sftp upload /tmp/sftp/20160202184928.tar.gz - ›/tmp/20160202184928.tar.gz Больше ошибок нет - person B. Shea; 02.02.2016

Попробуйте добавить эту строку в свой файл конфигурации deploy.rb:

default_run_options[:pty] = true
person Dario Barrionuevo    schedule 13.11.2012
comment
Спасибо, Дарио !, но результат все тот же, я также читал о добавлении ssh_options [: forward_agent] = true, без каких-либо других результатов. Я действительно думаю, что проблемы связаны с разрешениями, но я не знаю, как это исправить. Еще раз спасибо за ваши ответы и время, любые предложения будут приняты и извините за проблемы. - person Jorge; 14.11.2012

Мы изменили Capfile с

set :deploy_via, :copy

to

set :deploy_via, :remote_cache

и это сработало для нас. Мы не добавляли строку ниже

default_run_options[:pty] = true
person AbhinavD    schedule 01.04.2015