Class: ElasticDot::Command::Ps
- Defined in:
- lib/elasticdot/command/ps.rb
Class Method Summary collapse
- .list(opts) ⇒ Object
- .resize(settings, opts) ⇒ Object
- .restart(opts) ⇒ Object
- .scale(settings, opts) ⇒ Object
- .stop(opts) ⇒ Object
Class Method Details
.list(opts) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/elasticdot/command/ps.rb', line 65 def self.list(opts) require 'time' find_app! opts loop do info = api.get("/domains/#{@app}") tier = info['dot_tier'] dots = info['dots'] puts "=== web (#{tier['name']}): #{info['procfile']}" dots.each_with_index do |dot, i| now = Time.now elapsed = now - Time.parse(dot['started_at']) since = time_ago(now - elapsed) puts "web.#{i+1}: up #{since} cpu: #{dot['cpu_load']}%" end break unless opts[:follow] sleep 2 system 'clear' end end |
.resize(settings, opts) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/elasticdot/command/ps.rb', line 2 def self.resize(settings, opts) find_app! opts params = apps_info @app web = nil settings.each do |s| p, v = s.split('=',2) web = v and break if p == 'web' end unless web puts 'At the moment you can only resize web processes' exit 1 end params[:tier] = web api.put "/websites/#{@app}/scaling", params spinner "Resizing dots and restarting specified processes..." do loop do sleep 3 info = api.get "/domains/#{@app}" break if info['status'] == 'active' end end end |
.restart(opts) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/elasticdot/command/ps.rb', line 92 def self.restart(opts) find_app! opts api.post "/apps/#{@app}/restart" spinner 'Restarting dots...' do loop do sleep 3 info = api.get "/domains/#{@app}" break if info['status'] == 'active' end end end |
.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 |
.stop(opts) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/elasticdot/command/ps.rb', line 106 def self.stop(opts) find_app! opts spinner "Stopping dots..." do api.post "/apps/#{@app}/stop" end end |