deploy.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #---
  2. # Excerpted from "Agile Web Development with Rails",
  3. # published by The Pragmatic Bookshelf.
  4. # Copyrights apply to this code. It may not be used to create training material,
  5. # courses, books, articles, and the like. Contact us if you are in doubt.
  6. # We make no guarantees that this code is fit for any purpose.
  7. # Visit http://www.pragmaticprogrammer.com/titles/rails4 for more book information.
  8. #---
  9. # be sure to change these
  10. set :user, 'rubys'
  11. set :domain, 'depot.pragprog.com'
  12. set :application, 'depot'
  13. # adjust if you are using RVM, remove if you are not
  14. $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
  15. require "rvm/capistrano"
  16. set :rvm_ruby_string, '1.9.2'
  17. set :rvm_type, :user
  18. # file paths
  19. set :repository, "#{user}@#{domain}:git/#{application}.git"
  20. set :deploy_to, "/home/#{user}/#{domain}"
  21. # distribute your applications across servers (the instructions below put them
  22. # all on the same server, defined above as 'domain', adjust as necessary)
  23. role :app, domain
  24. role :web, domain
  25. role :db, domain, :primary => true
  26. # you might need to set this if you aren't seeing password prompts
  27. # default_run_options[:pty] = true
  28. # As Capistrano executes in a non-interactive mode and therefore doesn't cause
  29. # any of your shell profile scripts to be run, the following might be needed
  30. # if (for example) you have locally installed gems or applications. Note:
  31. # this needs to contain the full values for the variables set, not simply
  32. # the deltas.
  33. # default_environment['PATH']='<your paths>:/usr/local/bin:/usr/bin:/bin'
  34. # default_environment['GEM_PATH']='<your paths>:/usr/lib/ruby/gems/1.8'
  35. # miscellaneous options
  36. set :deploy_via, :remote_cache
  37. set :scm, 'git'
  38. set :branch, 'master'
  39. set :scm_verbose, true
  40. set :use_sudo, false
  41. set :rails_env, :production
  42. namespace :deploy do
  43. desc "cause Passenger to initiate a restart"
  44. task :restart do
  45. run "touch #{current_path}/tmp/restart.txt"
  46. end
  47. desc "reload the database with seed data"
  48. task :seed do
  49. run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
  50. end
  51. end
  52. after "deploy:update_code", :bundle_install
  53. desc "install the necessary prerequisites"
  54. task :bundle_install, :roles => :app do
  55. run "cd #{release_path} && bundle install"
  56. end