I've used an approach very similar to Simon Harris's (http://
www.redhillconsulting.com.au/blogs/simon/archives/000359.html) for
deploying to staging & production environments but using cap 1.99.1.

This means that I have an extra task for each environment:

desc "Settings specific to staging environment"
task :staging do
  set :rails_env, "staging"
  set :mongrel_port, "7700"
end

desc "Settings specific to production environment"
task :production do
  set :rails_env, "production"
  set :mongrel_port, "8800"
end

This means I have to type 'cap staging deploy:cold' for example. If I
forget and type 'cap deploy:cold' things break in a not-terribly-
elegant way with an exception being thrown.

To get round this I put in a before hook for deploy, start & stop to
ensure that the staging or production tasks have been called:

set :rails_env, nil
task :check_rails_env do
  if rails_env.nil?
    puts
    puts "Usage: cap staging <task>     - runs task on staging
environment"
    puts "   or: cap production <task>  - runs task on production
environment"
    puts
    exit(1)
  end
end

before :deploy, :check_rails_env
before "deploy:start", :check_rails_env
before "deploy:stop", :check_rails_env

Is it possible to specify a wildcard for before, e.g.

before "deploy:*", :check_rails_env

or is there a more elegant way of making rails_env a prerequisite for
all tasks, or perhaps all tasks in a namespace?

-Chrisl


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to