Class: Qops::Deploy
- Inherits:
-
Thor
- Object
- Thor
- Qops::Deploy
- Includes:
- DeployHelpers
- Defined in:
- lib/qops/deployment/app.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Allow thor to exit on any failure and return status code 1.
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
Allow thor to exit on any failure and return status code 1
90 91 92 |
# File 'lib/qops/deployment/app.rb', line 90 def self.exit_on_failure? true end |
Instance Method Details
#app ⇒ Object
7 8 9 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/qops/deployment/app.rb', line 7 def app initialize_run instances = config.deploy_type == 'staging' ? [retrieve_instance].compact : retrieve_instances online_instances = instances.select { |instance| instance.status == 'online' } raise 'Could not find any running instance(s) to deploy to. Perhaps you need to run "qops:instance:up" first' if online_instances.empty? if config.deploy_type == 'staging' puts "Preparing to deploy branch #{revision_used} to instance #{online_instances.first.hostname}" else puts "Preparing to deploy default branch to all (online) servers (#{online_instances.map(&:hostname).join(', ')})" end base_deployment_params = { stack_id: config.stack_id, command: { name: 'deploy' } } if !config.application_id Qops::Environment.print_with_colour('No application specified. Exiting without application deployment.') exit(0) else base_deployment_params[:app_id] = config.application_id end base_deployment_params[:custom_json] = custom_json.to_json if config.deploy_type != 'production' manifest = { environment: config.deploy_type } # Deploy the first instance with migration on first_instance = online_instances.first print "Migrating and deploying first instance (#{first_instance.hostname}) ..." deployment_params = base_deployment_params.deep_dup should_migrate = !config.option?(:migrate) || config.option?(:migrate) && config.migrate == true deployment_params[:command][:args] = { migrate: ['true'] } if should_migrate run_opsworks_command(deployment_params, [first_instance.instance_id]) ping_slack( 'Quandl::Slack::Release', "Deployed and migrated instance '#{first_instance.hostname}'", 'success', manifest.merge( app_name: config.app_name, command: 'deploy + migrate', migrate: should_migrate.to_s, completed: Time.now, hostname: first_instance.hostname, instance_id: first_instance.instance_id ) ) tag_instance(first_instance) # Deploy any remaining instances with migration off for production return unless config.deploy_type == 'production' && online_instances.count > 1 print 'Deploying remaining instances ...' deployment_params = base_deployment_params.deep_dup run_opsworks_command(deployment_params) online_instances.each { |instance| tag_instance(instance) } ping_slack( 'Quandl::Slack::Release', 'Deployed All Instances', 'success', manifest.merge( app_name: config.app_name, command: 'deploy', migrate: false, completed: Time.now, hostname: online_instances.map(&:hostname), instance_id: online_instances.map(&:instance_id) ) ) end |