我最近不得不对应用程序进行一些更新,这些应用程序在一年左右没有碰到过。当尝试使用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
行。
答案 0 :(得分:1)
如上所述:
这似乎是一个问题集:use_sudo,true。删除该行和任何需要sudo的命令似乎解决了这个问题。我仍然不完全清楚改变了什么 - 这使得这条线成为问题。它之前运作良好。
此外,我删除了default_run_options [:pty] = true行。
答案 1 :(得分:0)
在这些情况下发布 /config/deploy.rb 会有所帮助......
顺便说一句,你如何设置:deploy_via
设置?尝试将其更改为:remote_cache
(来自:copy
):
set :deploy_via, :remote_cache
看看会发生什么。