Class: Kamal::Cli::Traefik
Instance Method Summary collapse
- #boot ⇒ Object
- #details ⇒ Object
- #downgrade ⇒ Object
- #logs ⇒ Object
- #reboot ⇒ Object
- #remove ⇒ Object
- #remove_container ⇒ Object
- #remove_image ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Kamal::Cli::Base
Instance Method Details
#boot ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/kamal/cli/traefik.rb', line 3 def boot with_lock do on(KAMAL.traefik_hosts) do execute *KAMAL.registry.login execute *KAMAL.traefik.start_or_run end end end |
#details ⇒ Object
64 65 66 |
# File 'lib/kamal/cli/traefik.rb', line 64 def details on(KAMAL.traefik_hosts) { |host| puts_by_host host, capture_with_info(*KAMAL.traefik.info), type: "Traefik" } end |
#downgrade ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/kamal/cli/traefik.rb', line 126 def downgrade = { "version" => KAMAL.config.latest_tag }.merge() confirming "This will cause a brief outage on each host. Are you sure?" do host_groups = [:rolling] ? KAMAL.hosts : [ KAMAL.hosts ] host_groups.each do |hosts| host_list = Array(hosts).join(",") say "Downgrading to Traefik on #{host_list}...", :magenta run_hook "pre-traefik-reboot", hosts: host_list on(hosts) do |host| execute *KAMAL.auditor.record("Rebooted Traefik"), verbosity: :debug execute *KAMAL.registry.login "Stopping and removing kamal-proxy on #{host}, if running..." execute *KAMAL.traefik.cleanup_kamal_proxy "Stopping and removing Traefik on #{host}, if running..." execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false execute *KAMAL.traefik.remove_container execute *KAMAL.traefik.remove_image end KAMAL.with_specific_hosts(hosts) do invoke "kamal:cli:traefik:boot", [], reset_invocation(Kamal::Cli::Traefik) invoke "kamal:cli:app:boot", [], reset_invocation(Kamal::Cli::App) invoke "kamal:cli:prune:all", [], reset_invocation(Kamal::Cli::Prune) end run_hook "post-traefik-reboot", hosts: host_list say "Downgraded to Traefik on #{host_list}", :magenta end end end |
#logs ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kamal/cli/traefik.rb', line 74 def logs grep = [:grep] = [:grep_options] if [:follow] run_locally do info "Following logs on #{KAMAL.primary_host}..." info KAMAL.traefik.follow_logs(host: KAMAL.primary_host, grep: grep, grep_options: ) exec KAMAL.traefik.follow_logs(host: KAMAL.primary_host, grep: grep, grep_options: ) end else since = [:since] lines = [:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set on(KAMAL.traefik_hosts) do |host| puts_by_host host, capture(*KAMAL.traefik.logs(since: since, lines: lines, grep: grep, grep_options: )), type: "Traefik" end end end |
#reboot ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kamal/cli/traefik.rb', line 15 def reboot confirming "This will cause a brief outage on each host. Are you sure?" do with_lock do host_groups = [:rolling] ? KAMAL.traefik_hosts : [ KAMAL.traefik_hosts ] host_groups.each do |hosts| host_list = Array(hosts).join(",") run_hook "pre-traefik-reboot", hosts: host_list on(hosts) do execute *KAMAL.auditor.record("Rebooted traefik"), verbosity: :debug execute *KAMAL.registry.login execute *KAMAL.traefik.stop, raise_on_non_zero_exit: false execute *KAMAL.traefik.remove_container execute *KAMAL.traefik.run end run_hook "post-traefik-reboot", hosts: host_list end end end end |
#remove ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/kamal/cli/traefik.rb', line 95 def remove with_lock do stop remove_container remove_image end end |
#remove_container ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/kamal/cli/traefik.rb', line 104 def remove_container with_lock do on(KAMAL.traefik_hosts) do execute *KAMAL.auditor.record("Removed traefik container"), verbosity: :debug execute *KAMAL.traefik.remove_container end end end |
#remove_image ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/kamal/cli/traefik.rb', line 114 def remove_image with_lock do on(KAMAL.traefik_hosts) do execute *KAMAL.auditor.record("Removed traefik image"), verbosity: :debug execute *KAMAL.traefik.remove_image end end end |
#restart ⇒ Object
56 57 58 59 60 61 |
# File 'lib/kamal/cli/traefik.rb', line 56 def restart with_lock do stop start end end |