Method: ElasticDot::Command::Ps.scale

Defined in:
lib/elasticdot/command/ps.rb

.scale(settings, opts) ⇒ Object



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
# File 'lib/elasticdot/command/ps.rb', line 31

def self.scale(settings, opts)
  find_app! opts

  params = apps_info @app

  web, mode = nil
  settings.each do |s|
    p, v = s.split('=',2)
    web  = v if p == 'web'
    mode = v if p == 'mode'
  end

  unless web
    puts 'Usage: elasticdot ps:scale web=N [mode=auto|manual]'
    exit 1
  end

  params[:scaling] = mode if mode
  params[:dots]    = web

  api.put "/websites/#{@app}/scaling", params
  info = apps_info @app

  spinner "Scaling web processes..." do
    loop do
      sleep 3
      info = api.get "/domains/#{@app}"
      break if info['status'] == 'active'
    end
  end

  puts "Now running #{info[:dots]} dots"
end