lib/alpha_omega/deploy.rb in alpha_omega-0.0.111 vs lib/alpha_omega/deploy.rb in alpha_omega-0.0.113

- old
+ new

@@ -58,53 +58,51 @@ # what you are doing. Make sure you understand all the implications of your # changes if you do decide to muck with these! # ========================================================================= _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(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) } - - _cset(:version_dir) { releases.length > 0 ? "releases" : "" } - _cset :current_dir, "current" - _cset :service_dir, "service" - _cset :log_dir, "log" - _cset :releases, %w(alpha omega) - - _cset(:releases_path) { File.join(deploy_to, version_dir) } - _cset(:current_path) { File.join(deploy_to, current_dir) } - _cset(:service_path) { File.join(deploy_to, service_dir) } - _cset(:log_path) { File.join(deploy_to, log_dir) } - _cset(:service_drop) { File.join(deploy_to, ".#{service_dir}.d") } - _cset(:release_path) { File.join(releases_path, release_name) } - - _cset(:current_release) { release_path } _cset(:current_workarea) { capture("readlink #{current_path} || true").strip.split("/")[-1] } - - _cset(:previous_release) { + _cset(:release_name) { if releases.length > 0 w = current_workarea - releases.index(w) && releases[(releases.index(w)-1)%releases.length] || nil + stage = releases[((releases.index(w)?releases.index(w):-1)+1)%releases.length] + system "#{figlet} -w 200 on #{stage}" + stage else "" end } - _cset(:release_name) { + _cset :releases, [ "alpha", "beta", "omega" ] + _cset(:releases_dir) { releases.length > 0 ? "releases" : "" } + _cset :previous_dir, "previous" + _cset :current_dir, "current" + _cset :service_dir, "service" + _cset :log_dir, "log" + + + _cset(:releases_path) { File.join(deploy_to, releases_dir) } + _cset(:release_path) { File.join(releases_path, release_name) } + _cset(:previous_path) { if releases.length > 0 w = current_workarea - stage = releases[((releases.index(w)?releases.index(w):-1)+1)%releases.length] - system "#{figlet} -w 200 on #{stage}" - stage + releases.index(w) && releases[(releases.index(w)-1)%releases.length] || "" else "" end } + _cset(:current_path) { File.join(deploy_to, current_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(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release } _cset(:current_revision) { capture("cat #{current_path}/REVISION", :except => { :no_release => true }).chomp } _cset(:latest_revision) { capture("cat #{current_release}/REVISION", :except => { :no_release => true }).chomp } - _cset(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release } _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } # formerly: # @@ -113,11 +111,13 @@ # the timestamped release_path will be inaccurate, since the directory won't # actually exist. This variable lets tasks like symlink work either in the # standalone case, or during deployment. # # with persistent releases, the latest release is always the current release - _cset(:latest_release) { current_release } + _cset(:previous_release) { previous_path } + _cset(:current_release) { release_path } + _cset(:latest_release) { current_release } # ========================================================================= # deploy:lock defaults # ========================================================================= _cset(:lock_timeout) { 300 } @@ -515,11 +515,11 @@ puts "Found a chef lock by #{lock_user} #{epoch-lock_epoch} seconds ago: too old, deleting and ignoring" end end run_script = <<-SCRIPT - echo #{epoch} #{ENV['USER']} > #{log_path}/.#{application}_deploy_lock; + echo #{epoch} #{ENV['AO_USER']} > #{log_path}/.#{application}_deploy_lock; SCRIPT at_exit { self.unlock; } run run_script.gsub(/[\n\r]+[ \t]+/, " ") @@ -536,10 +536,10 @@ run_script = <<-SCRIPT set -e; cd #{release_path}; SCRIPT run_script += <<-SCRIPT - #{ruby_loader} bundle check 2>&1 > /dev/null || { #{ruby_loader} bundle install --quiet --local #{bundler_options} && #{ruby_loader} bundle check; }; + #{ruby_loader} bundle check 2>&1 > /dev/null || { #{ruby_loader} bundle install --quiet --local #{bundler_options} && #{ruby_loader} bundle check > /dev/null; }; SCRIPT run run_script.gsub(/[\n\r]+[ \t]+/, " ") end end