PageRenderTime 44ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/soe/parasquid-cs2001
Ruby | 84 lines | 59 code | 21 blank | 4 comment | 0 complexity | 6beae205af8b83d17fa9796089ba0f65 MD5 | raw file
  1. require "bundler/capistrano"
  2. require "rvm/capistrano"
  3. set :whenever_command, "bundle exec whenever"
  4. load 'deploy/assets'
  5. load "config/recipes/base"
  6. set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
  7. set :application, "cs2001"
  8. set :server_name, 'cs2001.parasquid.com'
  9. set :repository, "ssh://git@bitbucket.org/parasquid/parasquid-cs2001.git"
  10. set :git_enable_submodules, true
  11. set :user, "tristan"
  12. set :deploy_to, "/home/#{user}/apps/#{application}"
  13. set :use_sudo, false
  14. set :deploy_via, :remote_cache
  15. # so there is no need to add specific server keys
  16. ssh_options[:forward_agent] = true
  17. namespace :ssh do
  18. task :start_agent do
  19. `ssh-add`
  20. end
  21. end
  22. before 'deploy:update_code', 'ssh:start_agent'
  23. # after "deploy:update", "foreman:export" # Export foreman scripts
  24. # after "deploy:update", "foreman:restart" # Restart application scripts
  25. default_run_options[:pty] = true
  26. set :scm, :git
  27. # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
  28. set :stages, %w(production staging)
  29. set :default_stage, "production"
  30. require 'capistrano/ext/multistage'
  31. namespace :deploy do
  32. task :restart do
  33. run "#{sudo} service rainbows_#{application} restart"
  34. end
  35. task :stop do
  36. run "#{sudo} service rainbows_#{application} stop"
  37. end
  38. end
  39. namespace :foreman do
  40. desc 'Export the Procfile to Ubuntu upstart scripts'
  41. task :export, :roles => :app do
  42. run "cd #{release_path} && rvmsudo bundle exec foreman export upstart /etc/init -a #{application} -u #{user} -l #{release_path}/log/foreman"
  43. end
  44. desc "Start the application services"
  45. task :start, :roles => :app do
  46. sudo "start #{application}"
  47. end
  48. desc "Stop the application services"
  49. task :stop, :roles => :app do
  50. sudo "stop #{application}"
  51. end
  52. desc "Restart the application services"
  53. task :restart, :roles => :app do
  54. run "sudo start #{application} || sudo restart #{application}"
  55. end
  56. end
  57. namespace :rails do
  58. desc "Open the rails console on one of the remote servers"
  59. task :console, :roles => :app do
  60. host = find_servers_for_task(current_task).first
  61. exec "ssh -p #{port || 22} -l #{user || 'root'} #{host} -t 'rvm_path=/home/#{user}/.rvm/ /home/#{user}/.rvm/bin/rvm-shell \"#{rvm_ruby_string}\" -c \"cd #{current_release} && bundle exec rails console #{stage}\"'"
  62. end
  63. end