2015-03-11 19 views
12

dopo cerco di distribuire la mia app via Capistrano al mio server ottengo questo messaggio di errore:Capistrano: database.yml file collegato non esiste sul my.server.ipadress

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 

mia deploy.rb è:

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 

Ho provato questo tut https://www.gorails.com/deploy/ubuntu/14.04, questo è il mio primo tentativo con Capistrano.

risposta

29

Basta creare manualmente il file /home/deploy/myrailsapp/shared/config/database.yml e regolarlo.

Capistrano non crea (o gestisce) file di configurazione fuori dalla scatola. Quindi, dovresti farlo manualmente o automatizzare utilizzando i propri script Capistrano, Puppet, Chef, Ansible.

+0

Ho cercato di alta e bassa cercando di ottenere scollarsi. Il tuo consiglio ha fatto il trucco. Grazie a @maxd. – Red

+0

Per me ho il file ma mi sta dando questo errore. L'ho persino aperto su vim! Perchè questo? –

4

Poiché preferisco avere i file al centro del server di distribuzione, utilizzo questa attività per distribuire i file di configurazione dalla directory di configurazione alla directory dei file collegati sul server delle app.

Questo utilizza rsync, poiché utilizzo capistrano-rsync per la distribuzione.

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" 
+0

Grazie! Funziona! –

0

Con Capistrano-rails 1.2.3, come sotto, inserirlo a deploy.rb

## Linked Files & Directories (Default None): 
set :linked_files, %w{config/database.yml config/secrets.yml config/nginx.conf} 
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}