instance method exec

Ruby on Rails 2.0.0

Since v1.9.3 Last seen in v2.11.0

Available in: v1.9.3 v2.0.0 v2.1.2 v2.2.2 v2.3.0 v2.4.0 v2.5.3 v2.6.1 v2.7.0 v2.8.2 v2.9.0 v2.10.1 v2.11.0

Signature

exec(*cmd)

No documentation comment.

Parameters

cmd rest
Source
# File lib/kamal/cli/app.rb, line 97
  def exec(*cmd)
    cmd = Kamal::Utils.join_commands(cmd)
    env = options[:env]
    case
    when options[:interactive] && options[:reuse]
      say "Get current version of running container...", :magenta unless options[:version]
      using_version(options[:version] || current_running_version) do |version|
        say "Launching interactive command with version #{version} via SSH from existing container on #{KAMAL.primary_host}...", :magenta
        run_locally { exec KAMAL.app(role: KAMAL.primary_role, host: KAMAL.primary_host).execute_in_existing_container_over_ssh(cmd, env: env) }
      end

    when options[:interactive]
      say "Get most recent version available as an image...", :magenta unless options[:version]
      using_version(version_or_latest) do |version|
        say "Launching interactive command with version #{version} via SSH from new container on #{KAMAL.primary_host}...", :magenta
        run_locally do
          exec KAMAL.app(role: KAMAL.primary_role, host: KAMAL.primary_host).execute_in_new_container_over_ssh(cmd, env: env)
        end
      end

    when options[:reuse]
      say "Get current version of running container...", :magenta unless options[:version]
      using_version(options[:version] || current_running_version) do |version|
        say "Launching command with version #{version} from existing container...", :magenta

        on(KAMAL.hosts) do |host|
          roles = KAMAL.roles_on(host)

          roles.each do |role|
            execute *KAMAL.auditor.record("Executed cmd '#{cmd}' on app version #{version}", role: role), verbosity: :debug
            puts_by_host host, capture_with_info(*KAMAL.app(role: role, host: host).execute_in_existing_container(cmd, env: env))
          end
        end
      end

    else
      say "Get most recent version available as an image...", :magenta unless options[:version]
      using_version(version_or_latest) do |version|
        say "Launching command with version #{version} from new container...", :magenta
        on(KAMAL.hosts) do |host|
          roles = KAMAL.roles_on(host)

          roles.each do |role|
            execute *KAMAL.auditor.record("Executed cmd '#{cmd}' on app version #{version}"), verbosity: :debug
            puts_by_host host, capture_with_info(*KAMAL.app(role: role, host: host).execute_in_new_container(cmd, env: env))
          end
        end
      end
    end
  end

Defined in lib/kamal/cli/app.rb line 97 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Kamal::Cli::App

Type at least 2 characters to search.

↑↓ navigate · open · esc close