/config/deploy.rb
Ruby | 102 lines | 73 code | 27 blank | 2 comment | 0 complexity | 46d74381fabd14df37f017b81e71ca90 MD5 | raw file
- require 'bundler/capistrano'
- require "aws/ses"
- require './config/boot'
- #require 'airbrake/capistrano'
- #require 'thinking_sphinx/capistrano''
- set :application, "Family Legacy"
- set :scm, :git
- set :repository, "git@bitbucket.org:joshlehman/bc-family-legacy-steward.git"
- set :scm_passphrase, ""
- set :deploy_to, "/srv/deploy"
- set :deploy_via, :copy
- set :user, "ubuntu"
- set :notify_emails, ["david@dhanson.org","josh@joshlehman.com"]
- server "family-legacy.nine70labs.com", :web, :app, :db, :primary => true
- set :deploy_env, 'production'
- set :rails_env, 'production'
- set :branch, 'master'
- ssh_options[:keys] = [File.join(ENV["HOME"],".ssh","familylegacy.pem")]
- starting_rev = nil
- namespace :deploy do
- task :restart, :roles => :web do
- run "cd #{current_path}; touch tmp/restart.txt"
- end
- end
- namespace :link do
- task :sphinx_conf do
- run "ln -sf /srv/deploy/shared/production.sphinx.conf /srv/deploy/current/config"
- end
- end
- namespace :sphinx do
- task :stop, :roles => :web, :on_error => :continue do
- run "kill $(pidof searchd)"
- sleep(5)
- end
- task :rebuild, :roles => :web, :on_error => :continue do
- run "cd #{current_path}; sudo chmod -R a+w *"
- run "cd #{current_path}; RAILS_ENV=production bundle exec rake ts:rebuild"
- end
- task :start, :roles => :web, :on_error => :continue do
- run "sudo chmod -R a+w #{current_path}"
- run "cd #{current_path}; RAILS_ENV=production bundle exec rake ts:start"
- end
- end
- namespace :js do
- task :compile_templates, :roles => :web do
- run "cd #{current_path}; RAILS_ENV=production bundle exec rake compile_templates"
- end
- end
- namespace :git do
- desc 'Shows a Git log between the current version on server and latest on HEAD'
- task :save_rev do
- starting_rev = current_revision
- end
- task :log_pending do
- desc "Send email log from git"
- ses = AWS::SES::Base.new(
- :access_key_id => 'AKIAJG5FVCAOAMC6XMUA',
- :secret_access_key => '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'
- )
- log = `git log --pretty=medium #{starting_rev}..HEAD`
- log = "The following changes have been released:\n\n" + log
- ses.send_email :to => self.notify_emails,
- :source => 'david@dhanson.org',
- :subject => 'Family Legacy Deployment Notice',
- :body => log
- end
- end
- namespace :deploy do
- task :assets do
- run "cd #{current_path} && bundle exec rake assets:precompile RAILS_ENV=#{rails_env}"
- end
- end
- before "deploy", "git:save_rev"
- after "deploy", "deploy:migrate", "js:compile_templates", "deploy:assets", "git:log_pending", "sphinx:stop", "link:sphinx_conf", "sphinx:rebuild"
- after "deploy:update", "deploy:cleanup"