lib/alpha_omega/deploy.rb in alpha_omega-0.0.182 vs lib/alpha_omega/deploy.rb in alpha_omega-0.0.183
- old
+ new
@@ -152,12 +152,14 @@
_cset(:deploy_revision) { capture("cat #{deploy_release}/REVISION").strip }
# =========================================================================
# deploy:lock defaults
# =========================================================================
- _cset(:want_unlock) { true }
+ _cset(:want_unlock) { true }
_cset(:lock_timeout) { 86400 }
+ _cset(:lock_name) { application }
+ _cset(:lock_path) { "#{log_path}/.#{lock_name}_deploy_lock" }
# =========================================================================
# These are helper methods that will be available to your recipes.
# =========================================================================
@@ -542,47 +544,57 @@
bootstrap_code
epoch = Time.now.to_i
locker = ''
- run "cat #{log_path}/.#{application}_deploy_lock 2>&- || true" do |ch, stream, data|
+ run "cat #{lock_path} 2>&- || true" do |ch, stream, data|
locker << data
end
if !locker.empty?
lock_epoch = locker.split[0].to_i
lock_user = locker.split[1]
lock_elasped = epoch-lock_epoch
if lock_elasped < lock_timeout
- true # don't do anything if locks timeout, jus advise unlock
+ true # don't do anything if lock times out, just advise unlock
end
system "#{figlet} failed to lock"
puts "deploy locked by #{lock_user} #{epoch-lock_epoch} seconds ago"
puts "use bin/unlock to remove this lock"
abort
end
run_script = <<-SCRIPT
- echo #{epoch} #{ENV['AO_USER']} > #{log_path}/.#{application}_deploy_lock;
+ echo #{epoch} #{ENV['AO_USER']} > #{lock_path};
SCRIPT
if want_unlock
at_exit { self.unlock; }
end
run run_script.gsub(/[\n\r]+[ \t]+/, " ")
end
+ task :lock_compare do
+ set :lock_name, :compare
+ lock
+ end
+
+ task :lock_migrate do
+ set :lock_name, :migrate
+ lock
+ end
+
task :dont_unlock do
set :want_unlock, false
end
task :unlock do
if want_unlock
- run "rm -f #{log_path}/.#{application}_deploy_lock"
+ run "rm -f #{lock_path}"
end
end
end # :deploy