in Rails

Pascal’s svn and Capistrano Cheat Sheet

Here’s my recipe to get a source tree commited into subversion, then setup Capistrano and then deploy the application on a production server.
I’ve done this many times, and everytime I stumble of one or more steps to find find what comes next, what path to use, etc. So here’s a note to hopefully settle this once and for all.

Assumes that the subversion database is created on under /home/psq/svn/domainsvn. Assumes that the initial “domain” directory contains trunk, tags and branches and that you are deploying the trunk.

cd domain
svn import . svn+ssh://

mkdir domainsvn
cd domainsvn
svn co svn+ssh:// .

cap -A .

svn add config/deploy.rb
svn add lib/tasks/capistrano.rake

edit deploy.rb
And initialize user, application, repository…

set :use_sudo, false
set :user, ‘psq’
set :application, “”
set :repository, “svn+ssh://{user}/svn/domainsvn/trunk”
set :deploy_to, “/home/#{user}/#{application}”

Replace defaulf roles

role :web, application
role :app, application
role :db,  application, :primary => true

Add at the end of deploy.rb. See A better alternative to killall for details.

desc “Restart the FCGI processes on the app server as a regular user.”
task :restart, :roles => :app do
  run “pkill -9 -u #{user} ruby”

Now you are ready for the first deployment.

rake remote:exec ACTION=setup

And finally, to deploy:

cap deploy [or]
cap -q deploy (for quiet output)

If you you use “migration”, as you should, to create the tables on the remote host, and every time you update the tables:

rake remote:migrate

This assumed that your app was fully configured to work in your hosting environment. And if you haven’t done that yet, now if the time to do it.

  1. I am trying to deploy via svn+ssh as the repository but get the following error
    ssh: Name or service not known
    svn: Connection closed unexpectedly

  2. I’m assuming you did replace “” by your svn hostname (I was just using as a placeholder and I guess I should have used to be less confusing, and that the path afterwards matches the location of your actual svn repository and that you have ssh access to that machine. Otherwise, you may want to try using svn: (svnserver needs to be running though).

    did you try to run checkout manually?

    svn co svn+ssh://{user}/svn/domainsvn/trunk

    I see a column “:” after your domain name, do you have that as part of the url, or is it part of the error message?

  3. have you tried to deploy locally on your host server???
    I am having huge ssh issues trying to deploy from to

    I am guessing that capistrano is degined to deploy remotely…but all I want to do is deploy from one subdomain to another…any ideas?

  4. Let me try to understand your setup.

    You have a machine, on that stage machine, you have working setup, and your RAILS_ROOT directory is hooked to svn.
    And you want to deploy from stage to live.
    From the sound of it, both live and stage are hosted on the same machine, and you can ssh to that machine.
    Is that correct?

    Assuming it is, let me offer a few thoughts.

    Capistrano does make much assumption as to where the deployment reside relative to your test/stage system. It will connect via ssh and issue commands remotely. If you can connect from your own computer, you should be able from stage to live.

    What is the full text of the error you are getting?

    Do you have local access to svn on your stage and live access? Or are you using svn: or http: to connect?

Comments are closed.