lib/cli/commands/apps.rb in vmc-0.3.7 vs lib/cli/commands/apps.rb in vmc-0.3.8
- old
+ new
@@ -25,35 +25,52 @@
display apps_table
end
alias :apps :list
- SLEEP_TIME = 0.5
+ SLEEP_TIME = 1
LINE_LENGTH = 80
# Numerators are in secs
- TICKER_TICKS = 15/SLEEP_TIME
+ TICKER_TICKS = 25/SLEEP_TIME
HEALTH_TICKS = 5/SLEEP_TIME
- TAIL_TICKS = 25/SLEEP_TIME
+ TAIL_TICKS = 45/SLEEP_TIME
GIVEUP_TICKS = 120/SLEEP_TIME
YES_SET = Set.new(["y", "Y", "yes", "YES"])
-
def start(appname, push = false)
app = client.app_info(appname)
+
return display "Application '#{appname}' could not be found".red if app.nil?
return display "Application '#{appname}' already started".yellow if app[:state] == 'STARTED'
+
+ banner = 'Staging Application: '
+ display banner, false
+
+ t = Thread.new do
+ count = 0
+ while count < TAIL_TICKS do
+ display '.', false
+ sleep SLEEP_TIME
+ count += 1
+ end
+ end
+
app[:state] = 'STARTED'
client.update_app(appname, app)
- count = log_lines_displayed = 0
- failed = false
- start_time = Time.now.to_i
+ Thread.kill(t)
+ clear(LINE_LENGTH)
+ display "#{banner}#{'OK'.green}"
banner = 'Starting Application: '
display banner, false
+ count = log_lines_displayed = 0
+ failed = false
+ start_time = Time.now.to_i
+
loop do
display '.', false unless count > TICKER_TICKS
sleep SLEEP_TIME
begin
break if app_started_properly(appname, count > HEALTH_TICKS)
@@ -185,13 +202,13 @@
services_to_delete = []
app_services = app[:services]
app_services.each { |service|
del_service = force && no_prompt ? 'Y' : 'N'
unless no_prompt || force
- del_service = ask("Provisioned service [#{service}] detected, would you like to delete it? [Yn]: ")
+ del_service = ask("Provisioned service [#{service}] detected, would you like to delete it? [yN]: ")
end
- services_to_delete << service unless del_service.upcase == 'N'
+ services_to_delete << service if del_service.upcase == 'Y'
}
display "Deleting application [#{appname}]: ", false
client.delete_app(appname)
display 'OK'.green
@@ -384,10 +401,11 @@
framework = VMC::Cli::Framework.detect(path)
framework_correct = ask("Detected a #{framework}, is this correct? [Yn]: ") if prompt_ok && framework
framework_correct ||= 'y'
if prompt_ok && (framework.nil? || framework_correct.upcase == 'N')
display "#{"[WARNING]".yellow} Can't determine the Application Type." unless framework
+ framework = nil if framework_correct.upcase == 'N'
choose do |menu|
menu.layout = :one_line
menu.prompt = "Select Application Type: "
menu.default = framework
VMC::Cli::Framework.known_frameworks.each do |f|
@@ -640,18 +658,23 @@
return unless prompt_ok
choose do |menu|
menu.header = "The following system services are available:"
menu.prompt = 'Please select one you wish to provision: '
menu.select_by = :index_or_name
+ service_choices = []
services.each do |service_type, value|
value.each do |vendor, version|
- menu.choice(vendor) do
- default_name = random_service_name(vendor)
- service_name = ask("Specify the name of the service [#{default_name}]: ")
- service_name = default_name if service_name.empty?
- create_service_banner(vendor, service_name)
- bind_service_banner(service_name, appname)
- end
+ service_choices << vendor
+ end
+ end
+ service_choices.sort!
+ service_choices.each do |vendor|
+ menu.choice(vendor) do
+ default_name = random_service_name(vendor)
+ service_name = ask("Specify the name of the service [#{default_name}]: ")
+ service_name = default_name if service_name.empty?
+ create_service_banner(vendor, service_name)
+ bind_service_banner(service_name, appname)
end
end
end
end