Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created August 6, 2013 20:14
Show Gist options
  • Save chewmanfoo/6168184 to your computer and use it in GitHub Desktop.
Save chewmanfoo/6168184 to your computer and use it in GitHub Desktop.
class CheckDeploymentWorker < GenericWorker
def do_perform(event_id)
@event = Deployment.find(event_id)
raise UserTerminatedException unless check_terminated("CheckDeploymentWorker", @event)
raise OutOfOrderException unless check_order("CheckDeploymentWorker", @event, "check_deployment")
@event.class.log_result(@event, "CheckDeploymentWorker::perform -> start")
@event.servers.each do |ts|
@task = "#{@ssh_cmd} ssh -q -o 'UserKnownHostsFile=/dev/null' -o 'StrictHostKeyChecking=no' #{ts.name} rpm -q #{@event.package}"
@task2 = "#{@ssh_cmd} ssh -q -o 'UserKnownHostsFile=/dev/null' -o 'StrictHostKeyChecking=no' #{ts.name} rpm -q #{@event.application_name}"
raise UnixFailedExitException unless perform_unix("CheckDeploymentWorker", @event, @task) || perform_unix_verify_result("CheckDeploymentWorker", @event, @task2, "greater", @event.package)
end
rescue UnixFailedExitException => e
logger.error "I caught an UnixFailedExitException! I'll try the Deploy again! #{e.message}"
DeployDeploymentWorker.perform_async(@event.id)
raise UnixFailedExitException
# this code should run upon successful completion
@event.class.log_result(@event, "CheckDeploymentWorker::perform -> end")
@event.class.log_result(@event, "CheckDeploymentWorker::perform -> SUCCESS: [#{@result}]")
@event.complete_review!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment