Sha256: 5e385838fe7fec48853cda65121035239a3b71ecaf9f1119a66c07f268ad141b

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Command
  class PsStop < Base
    NAME = "ps:stop"
    OPTIONS = [
      app_option(required: true),
      workload_option,
      wait_option("workload to not be ready")
    ].freeze
    DESCRIPTION = "Stops workloads in app"
    LONG_DESCRIPTION = <<~DESC
      - Stops workloads in app
    DESC
    EXAMPLES = <<~EX
      ```sh
      # Stops all workloads in app.
      cpl ps:stop -a $APP_NAME

      # Stops a specific workload in app.
      cpl ps:stop -a $APP_NAME -w $WORKLOAD_NAME
      ```
    EX

    def call
      @workloads = [config.options[:workload]] if config.options[:workload]
      @workloads ||= config[:app_workloads] + config[:additional_workloads]

      @workloads.each do |workload|
        step("Stopping workload '#{workload}'") do
          cp.set_workload_suspend(workload, true)
        end
      end

      wait_for_not_ready if config.options[:wait]
    end

    private

    def wait_for_not_ready
      progress.puts

      @workloads.each do |workload|
        step("Waiting for workload '#{workload}' to not be ready", retry_on_failure: true) do
          cp.workload_deployments_ready?(workload, expected_status: false)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cpl-1.4.0 lib/command/ps_stop.rb
cpl-1.3.0 lib/command/ps_stop.rb
cpl-1.2.0 lib/command/ps_stop.rb
cpl-1.1.2 lib/command/ps_stop.rb
cpl-1.1.2.rc.0 lib/command/ps_stop.rb
cpl-1.1.1 lib/command/ps_stop.rb
cpl-1.1.0 lib/command/ps_stop.rb
cpl-1.0.4 lib/command/ps_stop.rb
cpl-1.0.3 lib/command/ps_stop.rb
cpl-1.0.2 lib/command/ps_stop.rb