Class: ElasticBeans::Command::UnsetEnv
- Inherits:
-
Object
- Object
- ElasticBeans::Command::UnsetEnv
- Defined in:
- lib/elastic_beans/command/unset_env.rb
Overview
:nodoc: all
Constant Summary collapse
- USAGE =
"unsetenv KEY [KEY]... | delvar | rmvar"
- DESC =
"Delete environment variables in the Elastic Beanstalk application"
- LONG_DESC =
<<-LONG_DESC Delete environment variables in the Elastic Beanstalk application. These are stored in S3 to avoid the 4096-byte limit on environment variables in Elastic Beanstalk. Restarts all running environments so they load the updated environment vars. Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. LONG_DESC
Instance Method Summary collapse
-
#initialize(application:, ui:) ⇒ UnsetEnv
constructor
A new instance of UnsetEnv.
- #run(*env_keys) ⇒ Object
Constructor Details
#initialize(application:, ui:) ⇒ UnsetEnv
Returns a new instance of UnsetEnv.
18 19 20 21 |
# File 'lib/elastic_beans/command/unset_env.rb', line 18 def initialize(application:, ui:) @application = application @ui = ui end |
Instance Method Details
#run(*env_keys) ⇒ Object
23 24 25 26 27 28 29 30 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 64 65 66 67 68 |
# File 'lib/elastic_beans/command/unset_env.rb', line 23 def run(*env_keys) environments = application.environments unready_environments = environments.select { |environment| environment.status != "Ready" } if unready_environments.any? raise EnvironmentsNotReady.new(environments: unready_environments) end threads = [] = ProgressBar.create(title: "Updating", total: nil, output: ui.stdout) Signal.trap("INT") do puts "\nInterrupting beans" puts "WARNING: Configuration update is partially applied, you should run this command again" raise Interrupt end Signal.trap("TERM") do puts "Terminating beans" puts "WARNING: Configuration update is partially applied, you should run this command again" raise SignalException.new("TERM") end .log("Updating configuration in #{application.name}...") application.env_vars.del(env_keys) .increment threads += environments.map { |environment| .log("Deleting env vars from `#{environment.name}'...") thread = Thread.new do environment.restart end .increment thread } loop do sleep 0.5 .increment if threads.none?(&:alive?) .total = .progress break end end threads.each(&:join) end |