class DockerRailsProxy::Stack
Constants
- RUNNING_STATUSES
Attributes
options[RW]
Private Instance Methods
opt_parser() { |opts| ... }
click to toggle source
# File lib/docker_rails_proxy/commands/stack.rb, line 78 def opt_parser @opt_parser ||= OptionParser.new do |opts| opts.banner = "Usage: bin/#{APP_NAME} stack #{self.class.name.demodulize.parameterize} [options]" opts.on( '--profile [PROFILE]', "Aws profile (Default: #{APP_NAME})" ) { |profile| options[:profile] = profile } yield opts if block_given? opts.on('-h', '--help', 'Display this screen') do puts opts exit end end end
stack_exist?(stack_name)
click to toggle source
# File lib/docker_rails_proxy/commands/stack.rb, line 45 def stack_exist?(stack_name) !stack_status(stack_name).blank? end
stack_status(stack_name)
click to toggle source
# File lib/docker_rails_proxy/commands/stack.rb, line 70 def stack_status(stack_name) %x(aws cloudformation describe-stacks \ --profile '#{options[:profile]}' \ | jq '.Stacks[] | select(.StackName == "#{stack_name}") | .StackStatus' \ | xargs ).strip end
wait_for_stack(stack_name)
click to toggle source
# File lib/docker_rails_proxy/commands/stack.rb, line 49 def wait_for_stack(stack_name) loop do case status = stack_status(stack_name) when 'CREATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS' puts "#{stack_name} still processing: #{status}" when *RUNNING_STATUSES puts "#{stack_name} stack stabilized: #{status}" break else $stderr.puts %{ There is a problem with the #{stack_name} stack: #{status} } exit 1 end sleep 10 end if stack_exist?(stack_name) end