2

我最近不得不对我大约一年没有接触过的应用程序进行一些更新。尝试使用 Capistrano(通过 Github)进行部署时,出现此错误:

[deploy:update_code] exception while rolling back: IOError, closed stream

此处记录的完整错误:https ://gist.github.com/2829751

在 Github SSH 安全恐慌之后,我重新安装了服务器的 SSH 密钥。远程服务器上不应该发生任何变化,并且之前的部署工作正常。我的本地系统上唯一的重大变化是迁移到 RVM。

任何想法是什么导致了错误?

这是我的 deploy.rb 文件,如果有帮助的话:

default_run_options[:pty] = true 

set :domain, 'xxx.xxx.xxx'
set :repository,  "XXX MY REPO XXX"
set :branch, 'master'
set :password, 'XXXXXXX'

set :deploy_to, "/var/www/#{domain}"

set :scm, :git
set :repository_cache, "git_cache"
set :deploy_via, :remote_cache

ssh_options[:paranoid] = false

set :user, "XXX"
set :runner, user
set :use_sudo, true
set :rails_env, 'production'

role :app, domain # multiple domains can be added here for parallel deployment (i.e. test_app)
role :web, domain
role :db,  domain, :primary => true

namespace :deploy do
  task :start, :roles => :app do
    run "touch #{release_path}/tmp/restart.txt"
  end

  task :stop, :roles => :app do
    # Do nothing.
  end

  desc "Restart Application"
  task :restart, :roles => :app do
    run "touch #{release_path}/tmp/restart.txt"
  end
end

deploy.task :cold do
  deploy.update
  deploy.create_db
  deploy.migrate
  deploy.restart # Change to start if we're using mongrels
end 

after "deploy:update_code", :update_config
after "deploy:restart", "delayed_job:restart"
after "deploy", "deploy:cleanup"

#links config files from shared to the release path and mongrel path after deployment
desc "Create all symlinks and files needed for app activation ofter deployment"
task :update_config, :roles => :web do
    run "ln -s -f /var/www/#{domain}/shared/database.yml #{release_path}/config/database.yml"
    run "ln -s -f /var/www/#{domain}/shared/app.yml #{release_path}/config/app.yml"
    run "ln -s -f /var/www/#{domain}/shared/cache #{release_path}/public/cache"
    run "ln -s -f /var/www/#{domain}/shared/survey_cache #{release_path}/public/surveys"
    run "ln -s -f /var/www/#{domain}/shared/surveys #{release_path}/surveys"
end

desc "changes ownership to cbdsm:git"
task :update_permissions, :roles => :web do
    sudo "chown -R #{user}:git /var/www/#{domain}"
end

namespace :delayed_job do
  desc "Start the delayed_job process"
  task :start, :roles => :app do
      run "cd #{current_path} && RAILS_ENV=#{rails_env} script/delayed_job -n 3 start"
  end

  desc "Stop the delayed_job process"
  task :stop, :roles => :app do
      run "cd #{current_path} && RAILS_ENV=#{rails_env} script/delayed_job stop"
  end

  desc "Restart the delayed_job process"
  task :restart, :roles => :app do
      delayed_job.stop
      delayed_job.start
  end
end

更新:这似乎是一个问题set :use_sudo, true。删除该行和任何需要 sudo 的命令似乎可以解决问题。我仍然不完全清楚发生了什么变化——这使得这条线有问题。它以前工作得很好。

此外,我删除了该default_run_options[:pty] = true行。

4

2 回答 2

1

如上贴:

这似乎是一个问题集:use_sudo,true。删除该行和任何需要 sudo 的命令似乎可以解决问题。我仍然不完全清楚发生了什么变化——这使得这条线有问题。它以前工作得很好。

此外,我删除了 default_run_options[:pty] = true 行。

于 2012-09-12T15:00:04.790 回答
0

在这些情况下,发布/config/deploy.rb会有所帮助......

顺便说一句,你如何设置:deploy_via设置?尝试将其更改为:remote_cache(从:copy):

set :deploy_via, :remote_cache

看看会发生什么。

于 2012-05-29T18:59:00.070 回答