Lee Hambley wrote:
> Rory,
>
> Actually there's a couple of ways to do this, can you paste a code
> sample, so I can help you, and confirm whether you're using home-grown
> multistage or the capistrano-ext gem?
>
> -- Lee Hambley
<snip>
Hi Lee
I am using capistrano-ext - below find a sample of my deploy.rb file:
************************************************************************
set :stages, ['development']
require 'capistrano/ext/multistage'
def get_var_or_set_default(options={})
if !exists?(options[:variable])
set(options[:variable],
Capistrano::CLI.ui.ask("#{options[:description]} [#{options[:default]}]: "))
end
if fetch(options[:variable]).empty?
set options[:variable], options[:default]
end
end
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
#set :deploy_to, "/usr/www/users/#{user}"
#set :deploy_via, :copy
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
set :scm, :git
set :scm_verbose, true
after "deploy:api", "deploy:cleanup"
# after "deploy:symlink", "deploy:update_crontab"
# add this as a test
namespace :deploy do
desc "Update your test API environment"
task :api, :roles => :api do
set :application, "API"
set :repository, "[email protected]:api.git"
ENV['ROLES']= "api" # This is to cheat the fact that copy copies to
all defined servers
set_api_vars
run "mkdir -p /usr/www/users/#{user}/releases"
run "mkdir -p /usr/www/users/#{user}/shared/log"
run "mkdir -p /usr/www/users/#{user}/shared/system"
update_code
symlink
run "cp #{database_yml_location}
#{current_release}/config/database.yml"
run "cp #{htaccess_location} #{current_release}/public/.htaccess"
run "cp #{htpasswd_location} #{current_release}/public/.htpasswd"
run "rm #{current_release}/public/index.html"
run "cd #{current_release} && rake #{api_environment}:refresh_db"
run "sed '1i\RAILS_ENV=\"#{api_environment}\"'
#{current_release}/config/environment.rb >
#{current_release}/config/environment.temp && mv
#{current_release}/config/environment.temp
#{current_release}/config/environment.rb"
run "chmod 755 #{current_release}/public"
run "chmod 755 #{current_release}/public/dispatch.*"
run "sudo /etc/init.d/apache restart"
end
task :apitest_rollback, :roles => :api do
rollback.code
run "sudo /etc/init.d/apache restart"
end
desc 'Reset your PHP test environment to some specified revision'
task :kon, :roles => :kon do
unset :application if exists?(:application)
unset :repository if exists?(:repository)
set :application, "PHP"
set :repository, "[email protected]:php.git"
ENV['ROLES']= "kon" # This is to cheat the fact that copy copies
to all defined servers
set_kon_vars
run "mkdir -p /usr/www/users/#{user}/releases"
strategy.deploy!
symlink
shared_htdir = "/usr/home/htdocs"
htdir = "#{current_release}/htdocs"
run "cp #{kon_htaccess_location} #{htdir}/.htaccess"
incdir = "#{current_release}/includes"
run "ln -s #{shared_pear_location} #{incdir}/pear"
tmpdir = "#{htdir}/templates/ui-default/en"
run "rm -rf #{tmpdir}/images"
run "ln -s #{shared_images_location} #{tmpdir}/./images"
admdir = "#{htdir}/admin/templates"
run "rm -rf #{admdir}/images"
run "ln -s #{shared_admin_images_location} #{admdir}/./images"
#run "chown -R #{user}:#{user} #{dir}/*"
end
task :set_kon_vars do
if exists?(:kon_user)
set :user, kon_user
else
set(:user, Capistrano::CLI.ui.ask("Username PHP will be hosted
under: "))
end
if exists?(:kon_branch)
set :branch, kon_branch
else
set(:branch, Capistrano::CLI.ui.ask("PHP branch to deploy: "))
end
get_var_or_set_default :variable => :shared_pear_location,
:description => "Location of shared pear directory", :default =>
"/usr/www/includes/pear"
get_var_or_set_default :variable => :shared_images_location,
:description => "Location of shared images directory", :default =>
"/usr/www/htdocs/templates/ui-default/en/images"
get_var_or_set_default :variable => :shared_admin_images_location,
:description => "Location of shared admin images directory", :default =>
"/usr/www/users/htdocs/admin/templates/images"
set :deploy_to, "/usr/www/users/#{user}"
set :deploy_via, :copy
set :kon_htaccess_location, "/usr/home/#{user}/deployment/.htaccess"
set :connections_yml_location,
"/usr/home/#{user}/deployment/connections.yml"
end
task :set_api_vars do
if exists?(:api_branch)
set :branch, api_branch
else
set(:branch, Capistrano::CLI.ui.ask("Branch to be deployed: "))
end
if exists?(:api_user)
set :user, api_user
else
set(:user, Capistrano::CLI.ui.ask("Username api will be hosted
under: "))
end
unless exists?(:api_environment)
set(:api_environment, Capistrano::CLI.ui.ask("Rails environment
that api will run as [development]: "))
end
if api_environment.empty?
set :api_environment, "development"
end
set :deploy_to, "/usr/www/users/#{user}"
set :deploy_via, :copy
set :database_yml_location, "/usr/home/#{user}/deployment/database.yml"
set :htaccess_location, "/usr/home/#{user}/deployment/.htaccess"
set :htpasswd_location, "/usr/home/#{user}/deployment/.htpasswd"
end
desc "Create a UAT environment consisting of kon, API"
task :default, :roles => :api do
api
kon
end
end
*****************************************************************
I have removed some paths etc - which is why the git repo paths are
weird, for example :)
Rory
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Capistrano" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.co.uk/group/capistrano?hl=en
-~----------~----~----~----~------~----~------~--~---