director/lib/director/lock_helper.rb
def with_release_locks(deployment_plan, opts = {})
      timeout = opts[:timeout] || 10
      release_names = deployment_plan.releases.map do |release|
        release.name
      end

      # Sorting to enforce lock order to avoid deadlocks
      locks = release_names.sort.map do |release_name|
        Config.logger.info("Acquiring release lock: #{release_name}")
        Lock.new("lock:release:#{release_name}", :timeout => timeout)
      end

      begin
        locks.each { |lock| lock.lock }
        yield
      ensure
        locks.reverse_each { |lock| lock.release }
      end
    end
# Surround with deployment releases lock.
#
# @param [DeploymentPlan] deployment plan.
# @option opts [Number] timeout how long to wait before giving up
# @return [void]
# @yield [void] block to surround
Surround with deployment releases lock.
Surround with deployment releases lock .
def with_release_locks(deployment_plan, opts = {})
      timeout = opts[:timeout] || 10
      release_names = deployment_plan.releases.map do |release|
        release.name
      end
      locks = release_names.sort.map do |release_name|
        Config.logger.info("Acquiring release lock: #{release_name}")
        Lock.new("lock:release:#{release_name}", :timeout => timeout)
      end
      begin
        locks.each { |lock| lock.lock }
        yield
      ensure
        locks.reverse_each { |lock| lock.release }
      end
    end
def with_release_locks ( deployment_plan , opts = { } ) timeout = opts [ :timeout ] || 10 release_names = deployment_plan . releases . map do | release | release . name end locks = release_names . sort . map do | release_name | Config . logger . info ( "Acquiring release lock: #{release_name}" ) Lock . new ( "lock:release:#{release_name}" , :timeout => timeout ) end begin locks . each { | lock | lock . lock } yield ensure locks . reverse_each { | lock | lock . release } end end
Surround with deployment releases lock.
Surround with deployment releases lock .
# Sorting to enforce lock order to avoid deadlocks
None
void
deployment_plan
opts
timeout how long to wait before giving up
timeout how long to wait before giving up
None
]
block to surround
block to surround