Guest User

Untitled

a guest
Mar 2nd, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. set :stages, %w(staging production)
  2. set :default_stage, "staging"
  3.  
  4. require 'capistrano/ext/multistage'
  5.  
  6. set :use_sudo, false # deploy user should own the application directory
  7.  
  8. set :user, 'deploy'
  9. set :runner, user
  10. default_run_options[:pty] = true
  11. ssh_options[:port] = 8910
  12.  
  13. set :domain, '000.000.000.000'
  14. set :application, "myapp.com"
  15. set(:deploy_to) { "/var/www/public_html/#{application}/#{stage}" }
  16.  
  17. set :scm, :git
  18. set :scm_verbose, true
  19. set :repository, 'git@github.com:myusername/myrepo.git'
  20. set :branch, 'master'
  21. set :deploy_via, :remote_cache
  22.  
  23. role :app, domain
  24. role :web, domain
  25. role :db, domain, :primary => true
  26.  
  27.  
  28. namespace :deploy do
  29. desc "Restarting mod_rails with restart.txt"
  30. task :restart, :roles => :app, :except => { :no_release => true } do
  31. run "touch #{current_path}/tmp/restart.txt"
  32. end
  33.  
  34. [:start, :stop].each do |t|
  35. desc "#{t} task is a no-op with mod_rails"
  36. task t, :roles => :app do ; end
  37. end
  38. end
  39.  
  40.  
  41. desc "Creates a generic database.yml in app/shared/conf"
  42. task :create_database_yml, :roles => :app do
  43.  
  44. database_configuration = <<-EOF
  45. production:
  46. adapter: mysql
  47. database: app_production
  48. username:
  49. password:
  50. encoding: utf8
  51. socket: /var/run/mysqld/mysqld.sock
  52.  
  53. staging:
  54. production
  55. EOF
  56.  
  57. run "mkdir -p #{deploy_to}/#{shared_dir}/conf"
  58. put database_configuration, "#{deploy_to}/#{shared_dir}/conf/database.yml"
  59. end
  60. after "deploy:setup", :create_database_yml
  61.  
  62.  
  63. desc "Copy app/shared/conf/database.yml to new release/config/database.yml"
  64. task :copy_database_yml, :roles => :app do
  65. db_config = "#{deploy_to}/#{shared_dir}/conf/database.yml"
  66. run "cp #{db_config} #{release_path}/config/database.yml"
  67. end
  68. after "deploy:update_code", :copy_database_yml
  69.  
  70.  
  71. desc "Setup the deplyment environment for staging"
  72. task :staging do
  73. set :stage, 'staging'
  74. set :rails_env, stage
  75. end
  76.  
  77.  
  78. desc "Setup the deplyment environment for production"
  79. task :production do
  80. set :stage, 'production'
  81. set :rails_env, stage
  82. end
Add Comment
Please, Sign In to add comment