# # # set :application, "www.allviant.com" # enable capistrano multistage set :stages, %w(staging production) set :default_stage, "dev" require "capistrano/ext/multistage" # set scm variables set :scm, :subversion set :deploy_via, :export set :scm_username, "hudson" set :scm_password, "4rU5hAbR" # this should be overridden in the various stages .rb files set :deploy_to, "/pub/www/#{application}" # ssh options for deployment set :user, "operator" # set owner and group for files on web server set :files_owner, "www-data" set :files_group, "sysadmin" # allow us to deploy from a branch # $ cap staging deploy -Sbranch=1.0 # # Or from a tag: # $ cap staging deploy -Stag=1.0.6 set :base_repository, "https://dev.allviant.net/svn/sites/www.allviant.com" if variables[:tag] set :repository, "#{base_repository}/tags/#{variables[:tag]}/site" elsif variables[:branch] set :repository, "#{base_repository}/branches/#{variables[:branch]}/site" else set :repository, "#{base_repository}/trunk/site" end # override some deployment tasks namespace :deploy do task :finalize_update do sudo "chown -R #{files_owner}:#{files_group} #{latest_release}" sudo "chmod -R 775 #{latest_release}" end namespace :web do task :disable, :roles => :web do on_rollback { delete "#{current_path}/maintenance.html" } require "erb" require "ostruct" # render and present a maintenance page vars = OpenStruct.new :deadline => ENV['UNTIL'], :reason => ENV['REASON'] template = File.readlines("./config/maintenance.rhtml").join() maintenance = ERB.new(template).result(vars.send(:binding)) put maintenance, "#{current_path}/maintenance.html", :mode => 0664 end task :enable, :roles => :web do # get rid of the maintenance page run "rm -f #{current_path}/maintenance.html" end end task :start do # nothing end task :stop do # nothing end task :restart do # nothing end end