I found the answer at topfunky.com and then updated the capistrano wiki entry here at Dreamhost.
In the wiki, it used to say create a subdomain for your app like this, “app.mydomain.com/current/public” which is correct, (don’t forget to add /current/public when creating the subdomain!), except that for capistrano to work a few steps later, you have to first manually delete the “/current/public & /current” folders (via ssh or ftp) that the dreamhost subdomain routine creates! The subdomain’s path will still be pointing to the /current/public folder (which you just deleted).
Capistrano’s ‘cap deploy’ command creates a symlink called ‘/current’ off your app’s subdomain. If there is already a folder called ‘/current’ there, it screws it up (which is the original issue I was having). After you have deleted the “/current/public & /current” folders, rerun ‘cap deploy’ and see if it creates a /current folder (symlink) off your app’s subdomain. You should not be able to view the contents of this folder via ssh or ftp since it’s really a symlink. Go to your subdomain in your browser, do you see the rails welcome?
If it still isn’t working, you may need to back track, removing the subversion repository (via dreamhost control panel) you just made for your app and manually remove the folders that ‘cap setup’ & ‘cap deploy’ make.
Removing capistrano created folders:
via ssh or ftp, below your app’s subdomain remove the following:
Assuming your app is working locally:
- Re-Create a subversion repository on the dreamhost server via their control panel
- make sure your local app’s environment.rb, public/dispatch.fcgi (#!/usr/bin/env ruby), public/.htaccess, deploy.rb files are edited.
- run “cap --apply-to .” (without quotes) in your local app folder (you do have capistrano and subversion installed locally, right?). This creates the config/deploy.rb file, which you then have to edit per the wiki (part of my deploy.rb file listed below for you). If you had already done this step before, it will ask if you want to overwrite config/deploy.rb and lib/tasks/capistrano.rake. Your choice. If you overwrite deploy.rb, you have to redit it again per the wiki. capistrano.rake file is not edited prior to finishing the deployment, so you can overwrite that one no problem.
- Copy (import) your current app from your local hard drive up to your subversion repository thusly (from within your local app folder):
svn import . http://svn.YOURDOMAIN.com/APPNAME -m ÒInitial ImportÓ This copies your local app up into subversion on the Dreamhost server. **If you don’t have subversion installed locally, this may not work as I typed it. I’ve seen other’s list the import line with an ssh element to it. I don’t do it that way.
- On your local machine, go up one folder level and rename your local app folder something like “originalAppName0”, so if it was blog, make it blog0. This is so the next step doesn’t wipe out your original local copy of your app if something goes wrong.
- from that same folder (just above your renamed app folder) ‘checkout’ a copy of the subversion app you just uploaded. This will re-copy the same app folder back down to your hard drive, creating the originally named app folder, but now it will be under subversion control: (fixes the ‘config is not a working copy’ error)
svn co http://svn.YOURDOMAIN.com/APPNAME
- Move into the newly created/downloaded app folder ‘cd appname’ and run: ‘cap setup’ which will create the releases folder and shared folder in your app’s subdomain (on dreamhost).
- From within your local app folder, run ‘cap deploy’ which finally looks at your dreamhost subversion repository, uploads your app as a new release version, creates the symlink to point to it and you’re in business.
I think for all future updates, simply run from your local app folder:
svn commit -m Òdescription of changesÓ (may need to resemble svn import command above. ie.svn commit http://svn.yourdomain.com/appname -m “description of changes” because the first way may be a local only commital?)
I seem to recall reading that the reaper errors are permission errors. However, I found elsewhere a better way to restart your app on the server than reaper. Here is the bottom half of my deploy.rb file, which includes not only the apache restart (replacing the reaper way), but also a cooler deploy method in general. This deploy puts up the maintenance page (turning off the website), then uploads the code, updates the release version (symlink), then runs migrations on the server (VERY handy if you are creating your tables/fields via migrations), restarts apache, removes the maintenance page turning back on the website. The whole thing is via a transaction, so if any part fails, then it puts it all back the way it was prior to running ‘cap deploy’.
Hope this works for you! I was able to create 5 other subdomains/subversionRepositories/Capistrano activated apps after finding that darn “delete /current/public folders” solution.
bottom half of my deploy.rb file:
#New deploy task!!
task :deploy, :roles => [:app, :db, :web] do
ENV[‘REASON’] = 'an application upgrade’
ENV[‘UNTIL’] = Time.now. (600).strftime("%H:%M %Z")
disable_web #put up the maintenance screen
update_code #update the code
symlink #fix the symlink
migrate #run migrations
restart #restart the server
enable_web #remove the maintenance screen
#better apache restart
desc "Restart the web server."
task :restart, :role => :app do
sudo "apachectl graceful"
If this is all too confusing, send me an email randy_at_walkersystems_dot_net and I’ll shoot you the step by step procedure I created for myself.