Sha256: 0a87eae844ff71f98b886ebac764a2ee5d8e78d126ac524ad5aaed0eb6031856
Contents?: true
Size: 1.71 KB
Versions: 36
Compression:
Stored size: 1.71 KB
Contents
require "cf/cli/app/base" module CF::App class Scale < Base desc "Update the instances/memory limit for an application" group :apps, :info input :app, :desc => "Application to update", :argument => true, :from_given => by_name(:app) input :instances, :desc => "Number of instances to run", :type => :numeric input :memory, :desc => "Memory limit" input :disk, :desc => "Disk quota" input :restart, :desc => "Restart app after updating?", :default => true def scale app = input[:app] if input.has?(:instances) instances = input[:instances, app.total_instances] end if input.has?(:memory) memory = input[:memory, app.memory] end if input.has?(:disk) disk = input[:disk, human_mb(app.disk_quota)] end unless instances || memory || disk instances = input[:instances, app.total_instances] memory = input[:memory, app.memory] end app.total_instances = instances if input.has?(:instances) app.memory = megabytes(memory) if input.has?(:memory) app.disk_quota = megabytes(disk) if input.has?(:disk) fail "No changes!" unless app.changed? with_progress("Scaling #{c(app.name, :name)}") do app.update! end needs_restart = app.changes.key?(:memory) || app.changes.key?(:disk_quota) if needs_restart && app.started? && input[:restart] invoke :restart, :app => app end end private def ask_instances(default) ask("Instances", :default => default) end def ask_memory(default) ask("Memory Limit", :choices => memory_choices, :default => human_mb(default), :allow_other => true) end end end
Version data entries
36 entries across 36 versions & 2 rubygems