PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy/vagrant.rb

https://bitbucket.org/phinze/environmentalist
Ruby | 62 lines | 46 code | 12 blank | 4 comment | 1 complexity | e9c433aa5c08e86531a1fd2849de82c7 MD5 | raw file
  1. set :rails_env, stage
  2. if ENV['LOCAL_DEPLOY']
  3. set :scm, :none
  4. set :repository, "."
  5. set :deploy_via, :copy
  6. set :copy_exclude, ['.git', 'iso']
  7. else
  8. set :scm, :git
  9. set :repository, "https://bitbucket.org/phinze/environmentalist/"
  10. end
  11. set :application, "environmentalist"
  12. set :deploy_to, "/srv/#{application}"
  13. vagrant_ssh_config = %x(vagrant ssh-config).split("\n")
  14. vagrant_host = vagrant_ssh_config.grep(/HostName/).first.split(' ').last
  15. vagrant_port = vagrant_ssh_config.grep(/Port/).first.split(' ').last
  16. vagrant_key = vagrant_ssh_config.grep(/IdentityFile/).first.split(' ').last
  17. set :use_sudo, false
  18. set :normalize_asset_timestamps, false
  19. ssh_options[:keys] = [vagrant_key]
  20. set :user, "vagrant"
  21. set :port, vagrant_port
  22. role :web, vagrant_host
  23. role :db, vagrant_host, :primary => true
  24. BP = 'bundle exec bluepill --no-privileged -c ./tmp/pids/bluepill -l ./log/bluepill.log'
  25. namespace :deploy do
  26. # Invoked during initial deployment
  27. task :start do
  28. run "cd #{current_path} && RAILS_ROOT='#{current_path}' RACK_ENV=#{rails_env} #{BP} load ./#{application}.pill"
  29. end
  30. # Invoked after each deployment afterwards
  31. task :restart do
  32. ignore_failure { run "cd #{current_path} && #{BP} stop unicorn && sleep 1 && #{BP} quit && sleep 1" }
  33. run "cd #{current_path} && RAILS_ROOT='#{current_path}' RACK_ENV=#{rails_env} #{BP} load ./#{application}.pill"
  34. end
  35. end
  36. namespace :rvm do
  37. desc 'Trust rvmrc file'
  38. task :trust_rvmrc do
  39. run "rvm rvmrc trust #{current_path}"
  40. end
  41. end
  42. after "deploy:update_code", "rvm:trust_rvmrc"
  43. ##
  44. # Shorthand for ignoring exceptions
  45. def ignore_failure(&block)
  46. begin
  47. yield
  48. rescue
  49. end
  50. end