所以我有这个问题在我的appname/current/config
,appname/shared/config
甚至appname/currentRelease/config/
中有一个database.yml
,但是当我执行相同的步骤来制作secretts.yml时在所有三个地方,它都拒绝或找不到。我在我的代码仓库中包含secrets.yml.sample
以允许我在生产时编辑它,当我部署但到目前为止它失败了。
我拥有的是:
require "bundler/capistrano"
server "adambalan.com", :web, :app, :db, primary: true
set :rvm_install_type, :stable
before "deploy", "rvm:install_rvm"
set :rvm_ruby_string, "2.1.0"
before "deploy", "rvm:install_ruby"
require "rvm/capistrano"
set :application, "aisiswriter"
set :user, "railsapps"
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git@github.com:AdamKyle/Aisis-Writer.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup"
after "deploy", "deploy:migrate"
namespace :rails do
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.rvm/scripts/rvm && cd #{current_path} && bundle exec rails console #{rails_env}'"
end
end
namespace :deploy do
desc "Start Application"
task :start, :roles => :app, except: {no_release: true} do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Stop Application (NOOP)"
task :stop, :roles => :app, except: {no_release: true} do
end
desc "Restart Application"
task :restart, :roles => :app, except: {no_release: true} do
run "touch #{current_path}/tmp/restart.txt"
end
task :setup_config, roles: :app do
run "mkdir -p #{shared_path}/config"
put File.read("config/database.yml.sample"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
task :setup_secrets, roles: :app do
put File.read("config/database.yml.sample"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config", "deploy:setup_secrets"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
task :symlink_secret, roles: :app do
run "ln -nfs #{shared_path}/config/secrets.yml #{release_path}/config/secrets.yml"
end
after "deploy:finalize_update", "deploy:symlink_config", "deploy:symlink_secret"
# desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
end
要注意的要点是:
task :setup_config, roles: :app do
run "mkdir -p #{shared_path}/config"
put File.read("config/database.yml.sample"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
task :setup_secrets, roles: :app do
put File.read("config/database.yml.sample"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config", "deploy:setup_secrets"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
task :symlink_secret, roles: :app do
run "ln -nfs #{shared_path}/config/secrets.yml #{release_path}/config/secrets.yml"
end
after "deploy:finalize_update", "deploy:symlink_config", "deploy:symlink_secret"
此对话的database.yml部分 - 如上所述 - 按预期工作。它的秘密没有。文件在那里(100%在那里)只是不确定为什么它不复制...
当我查看发布目录时,我看到:
AppName/
releases/
DateOfRelease/
config/
secrets.yml.sample # => Why you no copy over? You exist!!!!
思考?
答案 0 :(得分:1)
task :setup_secrets, roles: :app do
put File.read("config/database.yml.sample"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
这显然是错误的。
你需要
put File.read("config/secrets.yml.sample"), "#{shared_path}/config/secrets.yml"
因此,如果您的问题是secrets.yml
未创建,那就是问题(和解决方案),您可以创建database.yml
文件两次而不是secrets.yml
。