Guest User

Untitled

a guest
Jan 26th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
  2. default_run_options[:pty] = true # Must be set for the password prompt from git to work
  3. set :stages, %w(production staging)
  4. set :default_stage, "staging"
  5. require 'capistrano/ext/multistage'
  6. require "bundler/capistrano"
  7. require "rvm/capistrano"
  8.  
  9. set :application, "onlineapp"
  10. set :repository, "git@github.com:dzap/dingus.git"
  11.  
  12. set :rvm_ruby_string, '1.9.2@dingus'
  13. set :rvm_type, :system_wide
  14. set :rvm_bin_path, "/usr/local/bin"
  15.  
  16. set :scm, :git
  17. set :deploy_via, :remote_cache
  18. set :git_enable_submodules, 1
  19.  
  20. set :user, "dingus"
  21. set :use_sudo, false
  22.  
  23. set (:deploy_to) { "/var/www/#{application}/#{stage}" }
  24.  
  25. set :postgres_user, "dingus"
  26. set(:postgres_password) do
  27. Capistrano::CLI.ui.ask "PostgreSQL password: "
  28. end
  29.  
  30. set(:activemerchant_login) do
  31. Capistrano::CLI.ui.ask "ActiveMerchant login: "
  32. end
  33. set(:activemerchant_password) do
  34. Capistrano::CLI.ui.ask "ActiveMerchant password: "
  35. end
  36.  
  37. desc "Create database.yml in shared/config"
  38. after ("deploy:setup") do
  39. buffer = <<-EOF
  40. login: &login
  41. adapter: postgresql
  42. host: localhost
  43. username: <%= postgres_user %>
  44. password: <%= postgres_password %>
  45. encoding: UTF8
  46.  
  47. staging:
  48. database: <%= "#{application}_staging" %>
  49. <<: *login
  50.  
  51. production:
  52. database: <%= "#{application}_production" %>
  53. <<: *login
  54. EOF
  55.  
  56. database_configuration = ERB.new(buffer).result(binding)
  57. run "mkdir -p #{deploy_to}/#{shared_dir}/config"
  58. put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
  59. end
  60.  
  61. desc "Create activemerchant.yml in shared/config"
  62. after ("deploy:setup") do
  63. buffer = <<-EOF
  64. #{stage}:
  65. login: <%= activemerchant_login %>
  66. password: <%= activemerchant_password %>
  67. EOF
  68.  
  69. activemerchant_configuration = ERB.new(buffer).result(binding)
  70. run "mkdir -p #{deploy_to}/#{shared_dir}/config"
  71. put activemerchant_configuration, "#{deploy_to}/#{shared_dir}/config/activemerchant.yml"
  72. end
  73.  
  74.  
  75. desc "Link in the production database.yml, cache, and upload directory"
  76. after ("deploy:update_code") do
  77. run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
  78. run "ln -nfs #{deploy_to}/#{shared_dir}/config/activemerchant.yml #{release_path}/config/activemerchant.yml"
  79. run "ln -nfs #{deploy_to}/#{shared_dir}/uploads #{release_path}/public/uploads"
  80. run "ln -nfs #{deploy_to}/#{shared_dir}/cache #{release_path}/public/cache"
  81. end
  82.  
  83. namespace :deploy do
  84. task :start do ; end
  85. task :stop do ; end
  86. task :restart, :roles => :app, :except => { :no_release => true } do
  87. run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  88. end
  89. end
  90.  
  91. namespace :db do
  92. desc "Reset database by dumping schema, dropping it, loading schema, and reseeding"
  93. task :reset do
  94. run("cd #{deploy_to}/current && /usr/bin/env rake db:reset RAILS_ENV=#{rails_env}")
  95. end
  96. end
  97.  
  98. namespace :rake do
  99. desc "Run a task on a remote server. Append: task=[rake task name to invoke]"
  100. # run like: cap staging rake:invoke task=a_certain_task
  101. task :invoke do
  102. run("cd #{deploy_to}/current; /usr/bin/env rake #{ENV['task']} RAILS_ENV=#{rails_env}")
  103. end
  104. end
Add Comment
Please, Sign In to add comment