Class: Leeroy::Task::Terminate
- Includes:
- Helpers::AWS
- Defined in:
- lib/leeroy/task/terminate.rb
Constant Summary
Constants included from Helpers::Logging
Helpers::Logging::TRACE_FORMAT, Helpers::Logging::TRACE_LEVELS, Helpers::Logging::TRUNCATE_THRESHOLD
Instance Attribute Summary
Attributes included from Helpers::AWS
Attributes included from Helpers::State
Attributes included from Helpers::Env
Attributes included from Leeroy::Task
#args, #global_options, #options
Instance Method Summary collapse
Methods included from Helpers::AWS
#awsRequest, #buildS3ObjectName, #checkSemaphore, #clearSemaphore, #createTags, #destroyInstance, #ec2Request, #filterImages, #genSemaphore, #getApplicationImageIndex, #getApplicationInstanceName, #getGoldMasterImageIndex, #getGoldMasterInstanceName, #getImageByName, #getMaxImageIndex, #getRDSInstanceEndpoint, #getSemaphore, #getSgId, #getSubnetId, #getVpcId, #initialize, #rdsRequest, #s3Request, #setSemaphore
Methods inherited from Base
Methods included from Helpers::State
#dump_state, #load_state, #rotate_task_metadata, #state_from_pipe, #to_s
Methods included from Helpers::Logging
Methods included from Helpers::Env
Instance Method Details
#perform(args = self.args, options = self.options, global_options = self.global_options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/leeroy/task/terminate.rb', line 10 def perform(args = self.args, = self., = self.) begin super(args, , ) # destroy instance terminated = destroyInstance instanceid = self.state.instanceid if terminated.include?(instanceid) # clean up semaphore if present semaphore = self.state.semaphore if semaphore.nil? # guess at semaphore from instance ID s3_object = buildS3ObjectName(instanceid, 'semaphores') bucket = checkEnv('LEEROY_S3_BUCKET') semaphore = Leeroy::Types::Semaphore.new(bucket: bucket, object: s3_object, payload: '') end unless semaphore.nil? logger.debug "clearing semaphore #{semaphore}" clearSemaphore(semaphore) end logger.debug "clearing instanceid #{instanceid} from state" self.state.instanceid = nil end dump_state logger.debug "done performing for #{self.class}" rescue StandardError => e raise e end end |