Sha256: 7c9da24f76785079562b3792e6df6a837b9ba51512d9723b07e0152810537aa8

Contents?: true

Size: 1.62 KB

Versions: 35

Compression:

Stored size: 1.62 KB

Contents

module Aptible
  module CLI
    module Subcommands
      module Restart
        def self.included(thor)
          thor.class_eval do
            include Helpers::Operation
            include Helpers::App

            desc 'restart', 'Restart all services associated with an app'
            option :simulate_oom,
                   type: :boolean,
                   desc: 'Add this flag to simulate an OOM restart and test ' \
                         "your app's response (not recommended on production " \
                         'apps).'
            option :force,
                   type: :boolean,
                   desc: 'Add this flag to use --simulate-oom in a ' \
                         'production environment, which is not allowed by ' \
                         'default.'
            app_options
            def restart
              app = ensure_app(options)
              type = 'restart'

              if options[:simulate_oom]
                type = 'captain_comeback_restart'

                if app.account.type == 'production' && !options[:force]
                  e = 'This operation is designed for test purposes only, ' \
                      "but #{app.handle} is deployed in a production " \
                      'environment. Are you sure you want to do this? If ' \
                      'so, use the --force flag.'
                  raise Thor::Error, e
                end
              end

              operation = app.create_operation!(type: type)
              CLI.logger.info 'Restarting app...'
              attach_to_operation_logs(operation)
            end
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
aptible-cli-0.24.2 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.24.1 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.24.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.23.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.22.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.21.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.20.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.9 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.7 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.6 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.4 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.3 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.2 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.1 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.19.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.18.3 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.18.2 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.18.1 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.18.0 lib/aptible/cli/subcommands/restart.rb
aptible-cli-0.17.2 lib/aptible/cli/subcommands/restart.rb