Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

capistrano put() and upload() both failing

With capistrano, I am deploying a Rails application from Mac OS X 10.5 to CentOS 5.2

Note that deploy.rb and the server environment have not changed in over a year.

There is a task within our deploy.rb file called upload:

put(File.read( file ),"#{shared_path}/#{filename}", :via => :scp)

This fails each and every time with the following exception:

No such file or directory - /srv/ourapp/releases/20100104194410/config/database.yml

My local copy of config/database.yml is failing to upload properly. I've verified it's not our internet connection, as this happens on three different connections and two different systems.

I've also tried to swap out put() for upload() but get the same result; also, dropping :via => :scp, and/or trying to force :sftp instead similarly fails.

Relevant info:

$ cap -V Capistrano v2.5.10

$ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.6.0]

like image 956
Kyle Avatar asked Dec 11 '25 04:12

Kyle


2 Answers

If I understand your question correctly, it sounds like Capistrano is successfully uploading the files, but Rails is failing to start because it can't find the deploy.yml file. This might be happening during the Capistrano deploy as part of the deploy:restart task, making it look like a Capistrano error.

Based on the information you've given Capistrano is uploading the file to /svr/ourapp/shared/ and Rails is almost definitely looking for it in /svr/ourapp/releases/20100104194410/config/.

If that's the case, what you'll need to do is create a task which symlinks the shared database file to the expected location then add a hook so that task will be run after finalize_update. For instance:

task :symlink_database do
  run "ln -s #{shared_path}/database.yml #{latest_release}/config/database.yml"
end

after 'deploy:finalize_update', :symlink_database
like image 114
Emily Avatar answered Dec 12 '25 16:12

Emily


namespace :deploy do
  task :upload_settings, :roles => :app do
    run "mkdir -p #{shared_path}/config/"
    top.upload "config/database.yml", "#{shared_path}/config/database.yml", :via => :scp
  end

  task :symlink_yml, :roles => :app do
    run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
end

after 'deploy:setup', 'deploy:upload_settings'
after 'deploy:update_code', 'deploy:symlink_yml'
like image 39
airy Avatar answered Dec 12 '25 17:12

airy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!