Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
- default_run_options[:pty] = true # Must be set for the password prompt from git to work
- set :stages, %w(production staging)
- set :default_stage, "staging"
- require 'capistrano/ext/multistage'
- require "bundler/capistrano"
- require "rvm/capistrano"
- set :application, "onlineapp"
- set :repository, "git@github.com:dzap/dingus.git"
- set :rvm_ruby_string, '1.9.2@dingus'
- set :rvm_type, :system_wide
- set :rvm_bin_path, "/usr/local/bin"
- set :scm, :git
- set :deploy_via, :remote_cache
- set :git_enable_submodules, 1
- set :user, "dingus"
- set :use_sudo, false
- set (:deploy_to) { "/var/www/#{application}/#{stage}" }
- set :postgres_user, "dingus"
- set(:postgres_password) do
- Capistrano::CLI.ui.ask "PostgreSQL password: "
- end
- set(:activemerchant_login) do
- Capistrano::CLI.ui.ask "ActiveMerchant login: "
- end
- set(:activemerchant_password) do
- Capistrano::CLI.ui.ask "ActiveMerchant password: "
- end
- desc "Create database.yml in shared/config"
- after ("deploy:setup") do
- buffer = <<-EOF
- login: &login
- adapter: postgresql
- host: localhost
- username: <%= postgres_user %>
- password: <%= postgres_password %>
- encoding: UTF8
- staging:
- database: <%= "#{application}_staging" %>
- <<: *login
- production:
- database: <%= "#{application}_production" %>
- <<: *login
- EOF
- database_configuration = ERB.new(buffer).result(binding)
- run "mkdir -p #{deploy_to}/#{shared_dir}/config"
- put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
- end
- desc "Create activemerchant.yml in shared/config"
- after ("deploy:setup") do
- buffer = <<-EOF
- #{stage}:
- login: <%= activemerchant_login %>
- password: <%= activemerchant_password %>
- EOF
- activemerchant_configuration = ERB.new(buffer).result(binding)
- run "mkdir -p #{deploy_to}/#{shared_dir}/config"
- put activemerchant_configuration, "#{deploy_to}/#{shared_dir}/config/activemerchant.yml"
- end
- desc "Link in the production database.yml, cache, and upload directory"
- after ("deploy:update_code") do
- run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
- run "ln -nfs #{deploy_to}/#{shared_dir}/config/activemerchant.yml #{release_path}/config/activemerchant.yml"
- run "ln -nfs #{deploy_to}/#{shared_dir}/uploads #{release_path}/public/uploads"
- run "ln -nfs #{deploy_to}/#{shared_dir}/cache #{release_path}/public/cache"
- end
- namespace :deploy do
- task :start do ; end
- task :stop do ; end
- task :restart, :roles => :app, :except => { :no_release => true } do
- run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
- end
- end
- namespace :db do
- desc "Reset database by dumping schema, dropping it, loading schema, and reseeding"
- task :reset do
- run("cd #{deploy_to}/current && /usr/bin/env rake db:reset RAILS_ENV=#{rails_env}")
- end
- end
- namespace :rake do
- desc "Run a task on a remote server. Append: task=[rake task name to invoke]"
- # run like: cap staging rake:invoke task=a_certain_task
- task :invoke do
- run("cd #{deploy_to}/current; /usr/bin/env rake #{ENV['task']} RAILS_ENV=#{rails_env}")
- end
- end
Add Comment
Please, Sign In to add comment