ideaoforder
ideaoforder

Reputation: 1023

Capistrano Deploy Error

I've recently had to make some updates to an app that I haven't touched in about a year. When attempting to deploy with Capistrano (via Github), I get this error:

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

Full logged error here: https://gist.github.com/2829751

I reinstalled my server's SSH key after the Github SSH security scare. Nothing should have changed on the remote server, and deploying worked fine previously. The only significant change on my local system is moving to RVM.

Any ideas what's causing the error?

Here's my deploy.rb file, if that helps:

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

UPDATE: This seems to be a problem set :use_sudo, true. Removing that line and any commands which require sudo seemed to fix the problem. It's still not entirely clear to me what changed--that made that line problematic. It worked fine before.

Additionally, I removed the default_run_options[:pty] = true line.

Upvotes: 2

Views: 1756

Answers (2)

ideaoforder
ideaoforder

Reputation: 1023

As posted above:

This seems to be a problem set :use_sudo, true. Removing that line and any commands which require sudo seemed to fix the problem. It's still not entirely clear to me what changed--that made that line problematic. It worked fine before.

Additionally, I removed the default_run_options[:pty] = true line.

Upvotes: 1

In these cases post the /config/deploy.rb would help...

BTW, how do you set the :deploy_via setting? Try to change this to :remote_cache (from :copy):

set :deploy_via, :remote_cache

and see what happens.

Upvotes: 0

Related Questions