Guest User

Untitled

a guest
Jul 17th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. require "capistrano_colors"
  2.  
  3. set :host, "<my_domain_or_ip>"
  4. set :application, "app_name"
  5. set :user, "user_login"
  6.  
  7. set :use_sudo, false
  8. set :port, ENV['VPS_PORT'] || Proc.new { Capistrano::CLI.password_prompt("Port?: ") }
  9.  
  10. set :deploy_to, "/home/#{user}/public_html/#{application}"
  11.  
  12. set :scm, :git
  13. set :scm_user, ENV['SVN_USER'] || "#{user}"
  14. set :branch, "master"
  15. set :repository, "#{user}@my_git_server:repositories/#{application}.git"
  16.  
  17. role :app, host
  18. role :web, host
  19. role :db, host , :primary => true
  20.  
  21. set :database_yml_template, "database.example.yml"
  22.  
  23. namespace :deploy do
  24.  
  25. desc "Creates the database configuration on the fly"
  26. task :create_database_configuration, :roles => :app do
  27. require "yaml"
  28.  
  29. db_config = YAML::load_file("config/#{database_yml_template}")
  30. db_config.delete('test')
  31. db_config.delete('development')
  32.  
  33. db_config['production']['adapter'] = "mysql"
  34. db_config['production']['database'] = "#{application}"
  35. db_config['production']['username'] = "#{user}"
  36. # db_config['production']['password'] =
  37. db_config['production']['host'] = "localhost"
  38.  
  39. put YAML::dump(db_config), "#{release_path}/config/database.yml", :mode => 0664
  40. end
  41.  
  42. after "deploy:update_code", "deploy:create_database_configuration"
  43.  
  44. desc "Redefine deploy:restart"
  45. task :restart, :roles => :app do
  46. invoke_command "touch /home/#{user}/public_html/#{application}/current/config/database.yml"
  47. end
  48. end
Add Comment
Please, Sign In to add comment