lib/alpha_omega/deploy.rb in alpha_omega-1.3.38 vs lib/alpha_omega/deploy.rb in alpha_omega-1.3.39
- old
+ new
@@ -56,11 +56,14 @@
_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
_cset :last_pod, nil
_cset :success, false
- _cset (:figlet) { [%x(which figlet).strip].reject {|f| !(File.executable? f)}.first || echo }
+ _cset (:figlet) {
+ fig = %x(which figlet).strip].reject {|f| !(File.executable? f)}.first
+ fig ? "#{fig} -w 200" : "echo"
+ }
# =========================================================================
# services, logs
# =========================================================================
_cset :service_dir, "service"
@@ -129,11 +132,11 @@
}
_cset(:current_release_name) {
unless releases.empty?
w = current_workarea
workarea = releases[((releases.index(w)?releases.index(w):-1)+1)%releases.length]
- system "#{figlet} -w 200 on #{workarea}"
+ system "#{figlet} on #{workarea}"
workarea
else
""
end
}
@@ -356,11 +359,11 @@
end
run "ln -nfs #{rollback_release} #{previous_path}.new"
run "mv -T #{previous_path}.new #{previous_path}"
end
- system "#{figlet} -w 200 #{current_release_name} activated"
+ system "#{figlet} #{current_release_name} activated"
end
end
desc <<-DESC
Copy files to the currently deployed version. This is useful for updating \
@@ -433,16 +436,16 @@
This is called by the rollback sequence, and should rarely (if
ever) need to be called directly.
DESC
task :revision do
if previous_release
- system "#{figlet} -w 200 on #{previous_release_name}"
+ system "#{figlet} on #{previous_release_name}"
run "rm -f #{previous_path} #{next_path}"
run "ln -nfs #{previous_release} #{current_path}.new"
run "mv -T #{current_path}.new #{current_path}"
else
- system "#{figlet} -w 200 failed to rollback"
+ system "#{figlet} failed to rollback"
abort "could not rollback the code because there is no prior release"
end
end
desc <<-DESC
@@ -582,11 +585,14 @@
puts "use 'ao unlock' to remove this lock"
abort
end
if want_unlock
- at_exit { self.unlock; }
+ at_exit {
+ self.unlock;
+ self.successful;
+ }
end
run "echo #{epoch} #{ENV['_AO_DEPLOYER']} > #{lock_path}"
end
@@ -618,16 +624,19 @@
if want_unlock
run "rm -f #{lock_path}"
end
end
- task :successful, :only => { :primary => true } do
- set :success, true
- run_locally"#{figlet} success | perl -pe 's{( +)}{chr(46) x length($1)}e'"
+ task :successful
+ if success
+ system "#{figlet} success"
+ else
+ system "#{figlet} failed"
+ end
end
task :finished do
- successful
+ set :success, true
end
end # :deploy
end # Capistrano::Configuration
require 'alpha_omega/config/deploy'