Advertisement
michaelpastes

Untitled

Jun 28th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. require "bundler/capistrano"
  2.  
  3. server "198.xxx.xxx.xx.xxx", :web, :app, :db, primary: true
  4.  
  5. set :application, "qbruby2"
  6. set :user, "michael"
  7. set :deploy_to, "/home/#{user}/apps/#{application}"
  8. set :deploy_via, :remote_cache
  9. set :use_sudo, false
  10.  
  11. set :scm, "git"
  12. set :repository, "git@github.com:Me/blah.git"
  13. set :branch, "master"
  14.  
  15. default_run_options[:pty] = true
  16. ssh_options[:forward_agent] = true
  17.  
  18. after "deploy", "deploy:cleanup" # keep only the last 5 releases
  19.  
  20. namespace :deploy do
  21. %w[start stop restart].each do |command|
  22. desc "#{command} unicorn server"
  23. task command, roles: :app, except: {no_release: true} do
  24. run "/etc/init.d/unicorn_#{application} #{command}"
  25. end
  26. end
  27.  
  28. task :setup_config, roles: :app do
  29. sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
  30. sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
  31. run "mkdir -p #{shared_path}/config"
  32. put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
  33. puts "Now edit the config files in #{shared_path}."
  34. end
  35. after "deploy:setup", "deploy:setup_config"
  36.  
  37. task :symlink_config, roles: :app do
  38. run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  39. end
  40. after "deploy:finalize_update", "deploy:symlink_config"
  41.  
  42. desc "Make sure local git is in sync with remote."
  43. task :check_revision, roles: :web do
  44. unless `git rev-parse HEAD` == `git rev-parse origin/master`
  45. puts "WARNING: HEAD is not the same as origin/master"
  46. puts "Run `git push` to sync changes."
  47. exit
  48. end
  49. end
  50. before "deploy", "deploy:check_revision"
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement