Capistrano:my.server.ipadress上不存在链接文件database.yml

jui*_*icy 15 deployment ssh capistrano ruby-on-rails

在我尝试通过capistrano将我的应用程序部署到我的服务器后,我收到以下错误消息:

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 deploy@xx.xxx.xx.xxx: 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 deploy@xx.xxx.xx.xxx: exit
Run Code Online (Sandbox Code Playgroud)

我的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
Run Code Online (Sandbox Code Playgroud)

我尝试了这个tut https://www.gorails.com/deploy/ubuntu/14.04,这是我第一次尝试使用capistrano.

Max*_*kov 32

只需/home/deploy/myrailsapp/shared/config/database.yml手动创建文件并进行调整即可.

Capistrano不会创建(或管理)开箱即用的配置文件.所以,你应该做手工或自动使用自己的Capistrano脚本,Puppet,Chef,Ansible工具.


sco*_*nes 5

由于我更喜欢​​将我的文件放在部署服务器上,我使用此任务将配置文件中的配置文件部署到应用服务器上的链接文件目录.

这使用rsync,因为我使用capistrano-rsync进行部署.

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"
Run Code Online (Sandbox Code Playgroud)