Class: Beanstalkify::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/beanstalkify/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stack, cnames, config) ⇒ Application

config is an array of hashes:

:namespace, :option_name, :value


7
8
9
10
11
# File 'lib/beanstalkify/application.rb', line 7

def initialize(stack, cnames, config)
    @stack = stack
    @cnames = cnames.split(',')
    @config = config.map { |c| Hash[c.map { |k, v| [k.to_sym,v]}] }
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/beanstalkify/application.rb', line 3

def config
  @config
end

#stackObject

Returns the value of attribute stack.



3
4
5
# File 'lib/beanstalkify/application.rb', line 3

def stack
  @stack
end

Instance Method Details

#deploy!(archive, env) ⇒ Object

Deploy an archive to an environment. If the environment doesn’t exist, it will be created.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/beanstalkify/application.rb', line 15

def deploy!(archive, env)
    archive.upload(Beanstalk.api)
    
    if env.status.empty?
        puts "Creating stack '#{@stack}' for #{archive.app_name}-#{archive.version}..."
        env.create!(archive, @stack, @cnames, @config)
        env.wait_until_status_is_not "Launching"
    else
        puts "Deploying #{archive.version} to #{env.name}..."
        env.deploy!(archive, @config)
        env.wait_until_status_is_not "Updating"
    end
    
    env.wait_until_healthy
    puts "Done. Visit http://#{env.url} in your browser."
    DeploymentInfo.new env, archive
end