PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/joshlehman/bc-family-legacy-steward
Ruby | 102 lines | 73 code | 27 blank | 2 comment | 0 complexity | 46d74381fabd14df37f017b81e71ca90 MD5 | raw file
  1. require 'bundler/capistrano'
  2. require "aws/ses"
  3. require './config/boot'
  4. #require 'airbrake/capistrano'
  5. #require 'thinking_sphinx/capistrano''
  6. set :application, "Family Legacy"
  7. set :scm, :git
  8. set :repository, "git@bitbucket.org:joshlehman/bc-family-legacy-steward.git"
  9. set :scm_passphrase, ""
  10. set :deploy_to, "/srv/deploy"
  11. set :deploy_via, :copy
  12. set :user, "ubuntu"
  13. set :notify_emails, ["david@dhanson.org","josh@joshlehman.com"]
  14. server "family-legacy.nine70labs.com", :web, :app, :db, :primary => true
  15. set :deploy_env, 'production'
  16. set :rails_env, 'production'
  17. set :branch, 'master'
  18. ssh_options[:keys] = [File.join(ENV["HOME"],".ssh","familylegacy.pem")]
  19. starting_rev = nil
  20. namespace :deploy do
  21. task :restart, :roles => :web do
  22. run "cd #{current_path}; touch tmp/restart.txt"
  23. end
  24. end
  25. namespace :link do
  26. task :sphinx_conf do
  27. run "ln -sf /srv/deploy/shared/production.sphinx.conf /srv/deploy/current/config"
  28. end
  29. end
  30. namespace :sphinx do
  31. task :stop, :roles => :web, :on_error => :continue do
  32. run "kill $(pidof searchd)"
  33. sleep(5)
  34. end
  35. task :rebuild, :roles => :web, :on_error => :continue do
  36. run "cd #{current_path}; sudo chmod -R a+w *"
  37. run "cd #{current_path}; RAILS_ENV=production bundle exec rake ts:rebuild"
  38. end
  39. task :start, :roles => :web, :on_error => :continue do
  40. run "sudo chmod -R a+w #{current_path}"
  41. run "cd #{current_path}; RAILS_ENV=production bundle exec rake ts:start"
  42. end
  43. end
  44. namespace :js do
  45. task :compile_templates, :roles => :web do
  46. run "cd #{current_path}; RAILS_ENV=production bundle exec rake compile_templates"
  47. end
  48. end
  49. namespace :git do
  50. desc 'Shows a Git log between the current version on server and latest on HEAD'
  51. task :save_rev do
  52. starting_rev = current_revision
  53. end
  54. task :log_pending do
  55. desc "Send email log from git"
  56. ses = AWS::SES::Base.new(
  57. :access_key_id => 'AKIAJG5FVCAOAMC6XMUA',
  58. :secret_access_key => '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'
  59. )
  60. log = `git log --pretty=medium #{starting_rev}..HEAD`
  61. log = "The following changes have been released:\n\n" + log
  62. ses.send_email :to => self.notify_emails,
  63. :source => 'david@dhanson.org',
  64. :subject => 'Family Legacy Deployment Notice',
  65. :body => log
  66. end
  67. end
  68. namespace :deploy do
  69. task :assets do
  70. run "cd #{current_path} && bundle exec rake assets:precompile RAILS_ENV=#{rails_env}"
  71. end
  72. end
  73. before "deploy", "git:save_rev"
  74. after "deploy", "deploy:migrate", "js:compile_templates", "deploy:assets", "git:log_pending", "sphinx:stop", "link:sphinx_conf", "sphinx:rebuild"
  75. after "deploy:update", "deploy:cleanup"