juicy
juicy

Reputation: 875

Capistrano: linked file database.yml does not exist on my.server.ipadress

after i try to deploy my app via capistrano to my server i get this error message:

DEBUG [605f198a] Finished in 0.084 seconds with exit status 1 (failed).
ERROR linked file /home/deploy/myrailsapp/shared/config/database.yml does not exist on xx.xxx.xx.xxx
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: exit

SystemExit: exit

Tasks: TOP => deploy:check:linked_files
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as [email protected]: exit

my deploy.rb is:

set :deploy_to, '/home/deploy/myrailsapp'
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}



namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end
  after :publishing, 'deploy:restart'
  after :finishing, 'deploy:cleanup'
end


namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end
end

i tried this tut https://www.gorails.com/deploy/ubuntu/14.04, this is my first try with capistrano.

Upvotes: 17

Views: 13077

Answers (3)

askrynnikov
askrynnikov

Reputation: 771

You can upload files using the rake task.

Add the gem to your Gemfile after setting up Capistrano, preferably in the :development group:

group :development do
  gem 'capistrano',      require: false
  gem 'capistrano-rake', require: false
end

Аdd it to your Capfile:

require 'capistrano/rake'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Create file lib/capistrano/tasks/setup.rake and add to it:

namespace :deploy do
  namespace :check do
    before :linked_files, :set_database_yml do
      on roles(:app), in: :sequence, wait: 10 do
        upload! 'config/database.yml', "#{shared_path}/config/database.yml"
      end
    end
  end
end

Upvotes: 1

scones
scones

Reputation: 3355

As i prefer to have my files central on the deployment server, i use this task to deploy the config files from the config dir to the linked files dir on the app server.

This uses rsync, since i use capistrano-rsync to deploy.

namespace :deploy do

  task :copy_config do
    on release_roles :app do |role|
      fetch(:linked_files).each do |linked_file|
        user = role.user + "@" if role.user
        hostname = role.hostname
        linked_files(shared_path).each do |file|
          run_locally do
            execute :rsync, "config/#{file.to_s.gsub(/.*\/(.*)$/,"\\1")}", "#{user}#{hostname}:#{file.to_s.gsub(/(.*)\/[^\/]*$/, "\\1")}/"
          end
        end
      end
    end
  end

end
before "deploy:check:linked_files", "deploy:copy_config"

Upvotes: 6

Maxim
Maxim

Reputation: 9981

Just create /home/deploy/myrailsapp/shared/config/database.yml file manually and adjust it.

Capistrano doesn't create (or manage) configuration file out of the box. So, you should do it manually or automate use own Capistrano scripts, Puppet, Chef, Ansible tools.

Upvotes: 38

Related Questions