Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Deploying to different locations with Capistrano (See related posts)

// description of your code here
In your deploy.rb file:

if ENV["SERVER"] && ENV["SERVER"] == "production"
  set :primary_server, "production.com"
  set :user, "ben"
elsif ENV["SERVER"] && ENV["SERVER"] == "staging"
  set :primary_server, "staging.local"
  set :user, "ben"
else
 ...
end

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



The you say:
rake deploy SERVER=staging

Comments on this post

cdb posts on Dec 06, 2006 at 02:12
I've done basically the same thing in a different manner. Not sure if it's any better or worse, but here's what I do:

set :application, "Your staging application"
....other settings for staging server....

desc "Set live application variables
task :live, :roles => :app do
  set :application, "Your live application"
  ....other settings for live server....
end


Then to deploy to staging its:

cap -a deploy


But to your live server its:

cap -a live deploy


You need to create an account or log in to post comments to this site.


Click here to browse all 4860 code snippets

Related Posts