Guest User

Untitled

a guest
Apr 11th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Capistrano::Configuration.instance(:must_exist).load do |c|
  2.  
  3. #===================================================================
  4. # These variables must be set, otherwise cap will fail
  5. #===================================================================
  6. set(:db_user) { abort 'Please configure the db_user variable before deploying.' }
  7. set(:db_pass) { abort 'Please configure the db_pass variable before deploying.' }
  8.  
  9. #===================================================================
  10. # You may need to override these variables
  11. #===================================================================
  12. set(:db_name) { application }
  13. set(:db_host, "localhost")
  14. set(:db_adapter, "mysql")
  15.  
  16.  
  17. namespace :swig505 do
  18. namespace :db do
  19.  
  20. desc <<-DESC
  21. Setup the database.yml file in shared/config
  22. DESC
  23. task :setup_config, :roles => :app do
  24. database_configuration = <<-EOF
  25. #{rails_env}:
  26. adapter: #{db_adapter}
  27. host: #{db_host}
  28. username: #{db_user}
  29. password: #{db_pass}
  30. database: #{db_name}
  31. EOF
  32.  
  33. run "mkdir -p #{shared_path}/config"
  34. put database_configuration, "#{shared_path}/config/database.yml"
  35. end
  36.  
  37. desc <<-DESC
  38. Link the database.yml config from release_path to shared/config
  39. DESC
  40. task :link_config, :roles => :app do
  41. run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  42. end
  43.  
  44. end
  45. end
  46.  
  47. after "deploy:setup", "swig505:db:setup_config"
  48. after "deploy:symlink", "swig505:db:link_config"
  49.  
  50. end
Add Comment
Please, Sign In to add comment