Posted By

jordanbrock on 02/26/07


Tagged

ruby textdrive capistrano


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Capistrano Recipe for TextDrive


 / Published in: Ruby
 

  1. ## Set these vars up
  2.  
  3. set :application, "your_appname" # The name of the app
  4. set :user, "your_username" # Your Textdrive username
  5. set :domain, 'your_servername.textdrive.com' # Your domain
  6. set :path, "/users/home/#{user}" # The path to root of your site
  7. set :port, YOUR_PORT # Your port from Textdrive
  8. set :apps_directory, "railsapps" # The directory where you store your rails apps
  9.  
  10.  
  11. ## Don't have to worry about anything below here
  12.  
  13. set :repository, "http://url_for.yoursvnrepos.com/svn/#{application}/trunk"
  14. set :svn_username, Proc.new { "your_svn_username --password your_svn_password" }
  15.  
  16. set :deploy_to, "#{path}/#{apps_directory}/#{application}"
  17.  
  18. role :web, domain
  19. role :app, domain
  20. role :db, domain, :primary => true
  21.  
  22. # Space saving by Visi http://blogs.law.harvard.edu/vgondi/about
  23. set :keep_releases, 3
  24. set :checkout, "export"
  25.  
  26. task :cold_deploy do
  27. transaction do
  28. update_code
  29. symlink
  30. end
  31.  
  32. run "chmod 755 #{deploy_to}/current/script/spawn"
  33. run "#{deploy_to}/current/script/spawn"
  34. restart
  35. end
  36.  
  37. task :restart do
  38. run "#{deploy_to}/current/script/process/reaper -a reload"
  39. end
  40.  
  41. task :after_deploy do
  42. #run "cp #{path}/etc/#{application}.yml #{path}/sites/#{application}/current/config/database.yml"
  43.  
  44. #setup links to directories in the shared directory
  45. delete "#{current_path}/public/photos", :recursive => true
  46. run "ln -nfs #{shared_path}/photos #{current_path}/public/photos"
  47. end
  48.  
  49. desc <<-DESC
  50. Removes unused releases from the releases directory. By default, the last 5
  51. releases are retained, but this can be configured with the 'keep_releases'
  52. variable. This will use sudo to do the delete by default, but you can specify
  53. that run should be used by setting the :use_sudo variable to false.
  54. DESC
  55. task :cleanup do
  56. count = (self[:keep_releases] || 5).to_i
  57. if count >= releases.length
  58. logger.important "no old releases to clean up"
  59. else
  60. logger.info "keeping #{count} of #{releases.length} deployed releases"
  61. directories = (releases - releases.last(count)).map { |release|
  62. File.join(releases_path, release) }.join(" ")
  63.  
  64. delete "#{directories}", :recursive => true
  65. end
  66. end
  67.  
  68. task :after_setup, :roles=>[:web, :app, :db] do
  69.  
  70. end

Report this snippet  

You need to login to post a comment.