Sha256: c15c7b57e46d6ffc0073e8997a045cf7f1f4568b9ab42233da268f1de787fb28

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

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

      # Starts a specific workload in app.
      cpflow ps:start -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.reverse_each do |workload|
        step("Starting workload '#{workload}'") do
          cp.set_workload_suspend(workload, false)
        end
      end

      wait_for_ready if config.options[:wait]
    end

    private

    def wait_for_ready
      progress.puts

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cpflow-4.0.1 lib/command/ps_start.rb
cpflow-4.0.0 lib/command/ps_start.rb
cpflow-3.0.1 lib/command/ps_start.rb
cpflow-3.0.0 lib/command/ps_start.rb