From 99fa7598807dc18952b2eb54e80fc2d67de37105 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Thu, 4 Jul 2024 10:48:00 -0300 Subject: [PATCH] cleanup --- src/commands/scale.cr | 49 +++++++++---------------------------------- src/main.cr | 8 +++---- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/commands/scale.cr b/src/commands/scale.cr index 4a8bb88..26e7f81 100644 --- a/src/commands/scale.cr +++ b/src/commands/scale.cr @@ -1,14 +1,15 @@ module Faaso module Commands - # Bring up one or more funkos by name. - # - # This doesn't guarantee that they will be running the latest - # version, and it will try to recicle paused and exited containers. - # - # If there is no other way, it will create a brand new container with - # the latest known image and start it. - # - # If there are no images for the funko, it will fail to bring it up. + + # Controls a funko's scale + # + # Scale is how many instances are running. + # + # If it's increased, more instances are created. + # It it's decreased, instances are destroyed. + # + # In both cases stopped instances after the required + # scale is reached are deleted. struct Scale def local(options, name, scale) funko = Funko::Funko.from_names([name])[0] @@ -49,36 +50,6 @@ module Faaso return local(options, name, scale) end remote(options, name, scale) - - # case self - # when .running? - # # If it's already up, do nothing - # # FIXME: bring back out-of-date warning - # Log.info { "#{funko.name} is already up" } - # when .paused? - # # If it is paused, unpause it - # Log.info { "Resuming existing paused container" } - # funko.unpause - # when .exited? - # Log.info { "Starting function #{funko.name}" } - # Log.info { "Restarting existing exited container" } - # funko.start - # else - # # Only have an image, deploy from scratch - # Faaso.setup_network # We need it - # Log.info { "Creating and starting new container" } - # funko.create_container(autostart: true) - - # (1..5).each { |_| - # break if funko.running? - # sleep 0.1.seconds - # } - # if !funko.running? - # Log.warn { "Container for #{funko.name} is not running yet" } - # next - # end - # Log.info { "Container for #{funko.name} is running" } - # end end end end diff --git a/src/main.cr b/src/main.cr index fa0bf6a..62ce957 100644 --- a/src/main.cr +++ b/src/main.cr @@ -39,7 +39,7 @@ FaaSO CLI tool. Usage: faaso build FOLDER ... [-v=] [-l] faaso scale FUNKO [SCALE] [-v=] [-l] - faaso status FUNKO_NAME [-v=] [-l] + faaso status FUNKO [-v=] [-l] faaso export SOURCE DESTINATION [-v=] faaso secret [-d|-a] FUNKO SECRET [-v=] [-l] @@ -53,8 +53,8 @@ Options: DOC ans = Docopt.docopt(doc, ARGV) -pp! ans LogFormat.setup(ans["-v"].to_s.to_i) +Log.debug {ans} case ans when .fetch("build", false) @@ -62,9 +62,9 @@ when .fetch("build", false) when .fetch("export", false) Faaso::Commands::Export.new.run(ans, ans["SOURCE"].as(String), ans["DESTINATION"].as(String)) when .fetch("scale", false) - Faaso::Commands::Scale.new.run(ans, ans["FUNKO_NAME"].as(String), ans["SCALE"]) + Faaso::Commands::Scale.new.run(ans, ans["FUNKO"].as(String), ans["SCALE"]) when .fetch("status", false) - Faaso::Commands::Status.new.run(ans, ans["FUNKO_NAME"].as(String)) + Faaso::Commands::Status.new.run(ans, ans["FUNKO"].as(String)) when .fetch("secret", false) Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String)) end