Advertisement
Guest User

Untitled

a guest
Aug 1st, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. load 'deploy'
  2. set :user, 'deploy'
  3. set :use_sudo, false
  4. set :ssh_options, {:forward_agent => true}
  5. # =============
  6.  
  7. set :scm, 'git'
  8. set :scm_user, 'equal'
  9. set :repository, 'git@github.com:equal/equality.git'
  10. set :deploy_via, :remote_cache
  11.  
  12. # Deploy everything to equality-versions and symlink equality
  13. # Non-standard, but probably best.
  14. set :deploy_to, '/sites'
  15. set :version_dir, 'eq-versions'
  16. set :repository_cache, 'eq-versions/_cache'
  17. set :current_dir, "equality"
  18.  
  19. # We don't need shared
  20. set :shared_dir, ''
  21. set :shared_children, %w()
  22.  
  23. # ==========================================
  24.  
  25. set :branch, 'master'
  26.  
  27. set :stages, ['production']
  28.  
  29. task :production do
  30.     set :stage,     'production'
  31.     set :branch,    'master'
  32.     role :proxy,    "eq-production"
  33.     role :backend,  "eq-production"
  34. end
  35.  
  36. # ==========================================
  37.  
  38. namespace 'deploy' do
  39.  
  40.     desc <<-DESC
  41.         Prepare one or more servers for deployment. Override the default \
  42.         because we do not want to be bothered with the "shared" stuff in
  43.         our environment.
  44.     DESC
  45.     task :setup, :except => { :no_release => true } do
  46.         dirs = [deploy_to, releases_path]
  47.         run "mkdir -p #{dirs.join(' ')} && chown deploy:developers #{dirs.join(' ')} && chmod g+w #{dirs.join(' ')}"
  48.     end
  49.  
  50.     desc <<-DESC
  51.         Overriding this method so that we can use goddamn sudo
  52.         Updates the symlink to the most recently deployed version. Capistrano works \
  53.         by putting each new release of your application in its own directory. When \
  54.         you deploy a new version, this task's job is to update the `current' symlink \
  55.         to point at the new version. You will rarely need to call this task \
  56.         directly; instead, use the `deploy' task (which performs a complete \
  57.        deploy, including `restart') or the 'update' task (which does everything \
  58.        except `restart').
  59.     DESC
  60.     task :symlink, :except => { :no_release => true } do
  61.         on_rollback do
  62.             if previous_release
  63.                 run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
  64.             else
  65.                 logger.important "no previous release to rollback to, rollback of symlink skipped"
  66.             end
  67.         end
  68.         run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
  69.     end
  70.  
  71.     desc <<-DESC
  72.         [internal] Override this task, which assumes that \
  73.         you are working in a rails environment, which we \
  74.         are most certainly not.
  75.     DESC
  76.     task :finalize_update do
  77.         #run "cd #{current_path} && git checkout master"
  78.     end
  79.  
  80.     desc 'restart all servers (no-op for now)'
  81.     task :restart do
  82.     end
  83.  
  84. end
  85.  
  86.  
  87. namespace 'restart' do
  88.     desc 'restart all servers'
  89.     task :default do
  90.         proxy
  91.         backend
  92.     end
  93.  
  94.     desc 'restart proxy servers'
  95.     task :proxy, :roles => :proxy do
  96.         sudo('/etc/init.d/nginx restart')
  97.     end
  98.  
  99.     desc 'restart backend servers'
  100.     task :backend, :roles => :backend do
  101.         sudo('/etc/init.d/apache2 force-reload')
  102.     end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement