Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7038

Show
Ignore:
Timestamp:
06/16/07 13:51:12 (1 year ago)
Author:
minam
Message:

Make sure symlink and finalize_update tasks reference the most recent release when called by themselves

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r7036 r7038  
     1*SVN* 
     2 
     3* Make sure symlink and finalize_update tasks reference the most recent release when called by themselves [Jamis Buck] 
     4 
     5 
    16*1.99.2 (2.0 Preview 3)* June 15, 2007 
    2  
     7  
    38* CVS SCM module [Brian Phillips] 
    49 
  • tools/capistrano/lib/capistrano/recipes/deploy.rb

    r6949 r7038  
    3333set(:strategy)          { Capistrano::Deploy::Strategy.new(deploy_via, self) } 
    3434 
    35 set(:release_name)      { Time.now.utc.strftime("%Y%m%d%H%M%S") } 
     35set(:release_name)      { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") } 
    3636set(:releases_path)     { File.join(deploy_to, "releases") } 
    3737set(:shared_path)       { File.join(deploy_to, "shared") } 
     
    4848 
    4949set(:run_method)        { fetch(:use_sudo, true) ? :sudo : :run } 
     50 
     51# some tasks, like symlink, need to always point at the latest release, but 
     52# they can also (occassionally) be called standalone. In the standalone case, 
     53# the timestamped release_path will be inaccurate, since the directory won't 
     54# actually exist. This variable lets tasks like symlink work either in the 
     55# standalone case, or during deployment. 
     56set(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release } 
    5057 
    5158# ========================================================================= 
     
    146153  DESC 
    147154  task :finalize_update, :except => { :no_release => true } do 
    148     run "chmod -R g+w #{release_path}" if fetch(:group_writable, true) 
     155    run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) 
    149156 
    150157    # mkdir -p is making sure that the directories are there for some SCM's that don't 
    151158    # save empty folders 
    152159    run <<-CMD 
    153       rm -rf #{release_path}/log #{release_path}/public/system #{release_path}/tmp/pids && 
    154       mkdir -p #{release_path}/public && 
    155       mkdir -p #{release_path}/tmp && 
    156       ln -s #{shared_path}/log #{release_path}/log && 
    157       ln -s #{shared_path}/system #{release_path}/public/system && 
    158       ln -s #{shared_path}/pids #{release_path}/tmp/pids 
     160      rm -rf #{latest_release}/log #{latest_release}/public/system #{latest_release}/tmp/pids && 
     161      mkdir -p #{latest_release}/public && 
     162      mkdir -p #{latest_release}/tmp && 
     163      ln -s #{shared_path}/log #{latest_release}/log && 
     164      ln -s #{shared_path}/system #{latest_release}/public/system && 
     165      ln -s #{shared_path}/pids #{latest_release}/tmp/pids 
    159166    CMD 
    160167 
    161168    stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S") 
    162     asset_paths = %w(images stylesheets javascripts).map { |p| "#{release_path}/public/#{p}" }.join(" ") 
     169    asset_paths = %w(images stylesheets javascripts).map { |p| "#{latest_release}/public/#{p}" }.join(" ") 
    163170    run "find #{asset_paths} -exec touch -t #{stamp} {} \\;; true", :env => { "TZ" => "UTC" } 
    164171  end 
    165172 
    166173  desc <<-DESC 
    167     Updates the symlink to the deployed version. Capistrano works by putting \ 
    168     each new release of your application in its own directory. When you \ 
    169     deploy a new version, this task's job is to update the `current' symlink \ 
     174    Updates the symlink to the most recently deployed version. Capistrano works 
     175    by putting each new release of your application in its own directory. When 
     176    you deploy a new version, this task's job is to update the `current' symlink \ 
    170177    to point at the new version. You will rarely need to call this task \ 
    171178    directly; instead, use the `deploy' task (which performs a complete \ 
     
    175182  task :symlink, :except => { :no_release => true } do 
    176183    on_rollback { run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true" } 
    177     run "rm -f #{current_path} && ln -s #{release_path} #{current_path}" 
     184    run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}" 
    178185  end 
    179186