Class: Kamal::Cli::Server
Constant Summary
Constants inherited from Base
Base::AUTOMATIC_DEPLOY_LOCK_MESSAGE, Base::VERBOSITY
Instance Method Summary collapse
Methods inherited from Base
dynamic_command_class, exit_on_failure?, #initialize
Constructor Details
This class inherits a constructor from Kamal::Cli::Base
Instance Method Details
#bootstrap ⇒ Object
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 69 |
# File 'lib/kamal/cli/server.rb', line 38 def bootstrap modify(lock: true) do missing = [] on(KAMAL.hosts) do |host| unless execute(*KAMAL.docker.installed?, raise_on_non_zero_exit: false) if execute(*KAMAL.docker.superuser?, raise_on_non_zero_exit: false) info "Missing Docker on #{host}. Installing…" execute *KAMAL.docker.install unless execute(*KAMAL.docker.root?, raise_on_non_zero_exit: false) || execute(*KAMAL.docker.in_docker_group?, raise_on_non_zero_exit: false) execute *KAMAL.docker.add_to_docker_group begin execute *KAMAL.docker.refresh_session rescue IOError info "Session refreshed due to group change." end end else missing << host end end end if missing.any? raise "Docker is not installed on #{missing.join(", ")} and can't be automatically installed without having root access and either `wget` or `curl`. Install Docker manually: https://docs.docker.com/engine/install/" end run_hook "docker-setup" end end |
#exec(*cmd) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kamal/cli/server.rb', line 5 def exec(*cmd) raw = [:raw] if raw && [:interactive] raise ArgumentError, "Raw is not compatible with interactive" end with_raw_output(raw) do pre_connect_if_required cmd = Kamal::Utils.join_commands(cmd) hosts = KAMAL.hosts quiet = [:quiet] case when [:interactive] host = KAMAL.primary_host say "Running '#{cmd}' on #{host} interactively...", :magenta run_locally { exec KAMAL.server.run_over_ssh(cmd, host: host) } else say "Running '#{cmd}' on #{hosts.join(', ')}...", :magenta on(hosts) do |host| execute *KAMAL.auditor.record("Executed cmd '#{cmd}' on #{host}"), verbosity: :debug puts_by_host host, capture_with_info(cmd, strip: !raw), quiet: quiet, raw: raw end end end end |