vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.47 vs vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.48

- old
+ new

@@ -129,10 +129,12 @@ ask("Runtime", :choices => choices, :display => proc(&:name)) } input(:command, :desc => "Startup command for standalone app") { ask("Startup command") } + input :plan, :default => "D100", + :desc => "Application plan (e.g. D100, P200)" input :start, :type => :boolean, :default => true, :desc => "Start app after pushing?" input :restart, :type => :boolean, :default => true, :desc => "Restart app after updating?" input(:create_services, :type => :boolean, @@ -160,24 +162,25 @@ app = client.app app.name = name app.space = client.current_space if client.current_space app.total_instances = input[:instances] + app.production = input[:plan].capitalize.start_with?("P") detector = Detector.new(client, path) frameworks = detector.all_frameworks detected, default = detector.frameworks if detected.empty? - framework = input[:framework, frameworks, nil, false] + framework = input[:framework, frameworks] else detected_names = detected.collect(&:name).sort - framework = input[:framework, detected, default, true] + framework = input[:framework, detected, default, :other] if framework == :other input.forget(:framework) - framework = input[:framework, frameworks, nil, false] + framework = input[:framework, frameworks] end end runtimes = framework.runtimes || client.runtimes runtime = input[:runtime, runtimes] @@ -186,14 +189,14 @@ fail "Invalid runtime '#{input[:runtime]}'" unless runtime app.framework = framework app.runtime = runtime - app.command = input[:command] if framework == "standalone" + app.command = input[:command] if framework.name == "standalone" url = - if framework == "standalone" + if framework.name == "standalone" if (given = input[:url, "none"]) != "none" given end else input[:url, "#{name}.#{target_base}"] @@ -410,32 +413,38 @@ input(:memory, :desc => "Memory limit") { |default| ask("Memory Limit", :choices => memory_choices(default), :allow_other => true, :default => human_size(default * 1024 * 1024, 0)) } + input :plan, :default => "D100", + :desc => "Application plan (e.g. D100, P200)" input :restart, :type => :boolean, :default => true, :desc => "Restart app after updating?" def scale app = input[:app] instances = input.given(:instances) memory = input.given(:memory) + plan_name = input.given(:plan) - unless instances || memory + unless instances || memory || plan_name instances = input[:instances, app.total_instances] memory = input[:memory, app.memory] end megs = megabytes(memory) + production = plan_name && plan_name.capitalize.start_with?("P") memory_changed = megs != app.memory instances_changed = instances != app.total_instances + plan_changed = production != app.production - return unless memory_changed || instances_changed + return unless memory_changed || instances_changed || plan_changed with_progress("Scaling #{c(app.name, :name)}") do - app.total_instances = instances.to_i if instances - app.memory = megs if memory + app.total_instances = instances.to_i if instances_changed + app.memory = megs if memory_changed + app.production = production if plan_changed app.update! end if memory_changed && app.started? && input[:restart] invoke :restart, :app => app