lib/alpha_omega/deploy.rb in alpha_omega-0.0.152 vs lib/alpha_omega/deploy.rb in alpha_omega-0.0.153

- old
+ new

@@ -45,10 +45,12 @@ _cset :dir_perms, "0775" _cset :bundler_options, "--deployment --without development:test" _cset :ruby_loader, "" + _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } + _cset :current_pod, "default" _cset :last_pod, nil _cset :local_only, ENV['LOCAL_ONLY'] ? true : false _cset (:figlet) { [%x(which figlet).strip].reject {|f| !(File.executable? f)}.first || echo } @@ -61,11 +63,27 @@ _cset(:source) { Capistrano::Deploy::SCM.new(scm, self) } _cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) } _cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } } - _cset(:current_workarea) { capture("readlink #{current_path} || true").strip.split("/")[-1] } + _cset :releases, [ "alpha", "beta", "omega" ] + _cset(:releases_dir) { releases.length > 0 ? "releases" : "" } + _cset(:current_workarea) { capture("readlink #{current_path} || true").strip.split("/")[-1] || releases[0] } + + _cset :previous_dir, "previous" + _cset :current_dir, "current" + _cset :next_dir, "next" + _cset :compare_dir, "compare" + _cset :migrate_dir, "migrate" + + _cset :service_dir, "service" + _cset :log_dir, "log" + + _cset(:service_path) { File.join(deploy_to, service_dir) } + _cset(:service_drop) { File.join(deploy_to, ".#{service_dir}.d") } + _cset(:log_path) { File.join(deploy_to, log_dir) } + _cset(:rollback_release_name) { if releases.length > 0 w = current_workarea releases.index(w) && releases[(releases.index(w))%releases.length] else @@ -88,45 +106,36 @@ stage else "" end } - _cset (:release_name) { current_release_name } # compact _cset(:next_release_name) { if releases.length > 0 w = current_workarea releases.index(w) && releases[(releases.index(w)+1)%releases.length] else "" end } + _cset :compare_release_name, compare_dir + _cset :migrate_release_name, migrate_dir - _cset :releases, [ "alpha", "beta", "omega" ] - _cset(:releases_dir) { releases.length > 0 ? "releases" : "" } - _cset :previous_dir, "previous" - _cset :current_dir, "current" - _cset :next_dir, "next" - _cset :service_dir, "service" - _cset :log_dir, "log" - - _cset(:releases_path) { File.join(deploy_to, releases_dir) } _cset(:previous_path) { File.join(deploy_to, previous_dir) } _cset(:current_path) { File.join(deploy_to, current_dir) } _cset(:external_path) { current_path } _cset(:next_path) { File.join(deploy_to, next_dir) } - _cset(:service_path) { File.join(deploy_to, service_dir) } - _cset(:service_drop) { File.join(deploy_to, ".#{service_dir}.d") } - _cset(:log_path) { File.join(deploy_to, log_dir) } + _cset(:compare_path) { File.join(deploy_to, compare_dir) } + _cset(:migrate_path) { File.join(deploy_to, migrate_dir) } _cset(:rollback_revision) { capture("cat #{rollback_release}/REVISION", :except => { :no_release => true }).strip } _cset(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).strip } _cset(:current_revision) { capture("cat #{current_release}/REVISION", :except => { :no_release => true }).strip } _cset(:next_revision) { capture("cat #{next_release}/REVISION", :except => { :no_release => true }).strip } + _cset(:compare_revision) { capture("cat #{compare_release}/REVISION", :except => { :no_release => true }).strip } + _cset(:migrate_revision) { capture("cat #{migrate_release}/REVISION", :except => { :no_release => true }).strip } - _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } - # formerly: # # some tasks, like symlink, need to always point at the latest release, but # they can also (occassionally) be called standalone. In the standalone case, # the timestamped release_path will be inaccurate, since the directory won't @@ -137,10 +146,12 @@ _cset(:rollback_release) { File.join(releases_path, rollback_release_name) } _cset(:previous_release) { File.join(releases_path, previous_release_name) } _cset(:current_release) { File.join(releases_path, current_release_name) } _cset(:next_release) { File.join(releases_path, next_release_name) } + _cset(:compare_release) { File.join(releases_path, compare_release_name) } + _cset(:migrate_release) { File.join(releases_path, migrate_release_name) } # ========================================================================= # deploy:lock defaults # ========================================================================= _cset(:want_unlock) { true } @@ -386,11 +397,13 @@ desc <<-DESC Compares your application. DESC task :compare, :roles => :app, :except => { :no_release => true } do + set :current_release_name, "compare" update_code + run "ln -vnfs #{compare_release} #{compare_path}" end namespace :rollback do desc <<-DESC [internal] Points the current symlink at the previous revision. @@ -613,6 +626,5 @@ put full_log, "#{log_path}/#{application}-#{ENV["AO_USER"]}.log-#{Time.now.strftime('%Y%m%d-%H%M')}" end end end # Capistrano::Configuration -