Sha256: cf7d26d54f11e05128defc733c68723cd47c925b683d096ffa96d5b0b268539a

Contents?: true

Size: 1.87 KB

Versions: 24

Compression:

Stored size: 1.87 KB

Contents

module SimpleDeploy
  class Stack
    class Deployment
      class Status

        def initialize(args)
          @config   = SimpleDeploy.config
          @logger   = SimpleDeploy.logger
          @stack    = args[:stack]
          @ssh_user = args[:ssh_user]
          @name     = args[:name]
        end

        def clear_for_deployment?
          !deployment_in_progress?
        end

        def clear_deployment_lock(force=false)
          if deployment_in_progress? && force
            @logger.info "Forcing. Clearing deployment status."
            unset_deployment_in_progress
          end
        end

        def deployment_in_progress?
          @logger.debug "Checking deployment status for #{@name}."
          if attributes['deployment_in_progress'] == 'true'
            @logger.info "Deployment in progress for #{@name}."
            @logger.info "Started by #{attributes['deployment_user']}@#{attributes['deployment_datetime']}."
            true
          else
            @logger.debug "No other deployments in progress for #{@name}."
            false
          end
        end

        def set_deployment_in_progress
          @logger.debug "Setting deployment in progress by #{@ssh_user} for #{@name}."
          @stack.update :attributes => [ { 'deployment_in_progress' => 'true',
                                           'deployment_user'        => @ssh_user,
                                           'deployment_datetime'    => Time.now.to_s } ]
        end

        def unset_deployment_in_progress
          @logger.debug "Clearing deployment in progress for #{@name}."
          @stack.in_progress_update :attributes => [
                                      { 'deployment_in_progress' => 'false' } ],
                                    :caller => self
        end

        private

        def attributes
          @stack.attributes
        end

      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
simple_deploy-0.7.6.beta.1 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.5 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.4 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.3 lib/simple_deploy/stack/deployment/status.rb