fix: allow configurations without web roles

This commit is contained in:
Yoel Cabo
2023-11-12 09:39:07 +01:00
parent 8f53104d00
commit 87cb8c1f71
7 changed files with 31 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ class Kamal::Cli::Healthcheck < Kamal::Cli::Base
desc "perform", "Health check current app version"
def perform
return unless KAMAL.primary_role.running_traefik?
on(KAMAL.primary_host) do
begin
execute *KAMAL.healthcheck.run

View File

@@ -24,7 +24,7 @@ class Kamal::Commander
attr_reader :specific_roles, :specific_hosts
def specific_primary!
self.specific_hosts = [ config.primary_web_host ]
self.specific_hosts = [ config.primary_host ]
end
def specific_roles=(role_names)
@@ -36,7 +36,7 @@ class Kamal::Commander
end
def primary_host
specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_web_host
specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_host
end
def primary_role

View File

@@ -2,6 +2,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base
def run
web = config.role(:web)
return unless web.present?
docker :run,
"--detach",

View File

@@ -89,8 +89,12 @@ class Kamal::Configuration
roles.flat_map(&:hosts).uniq
end
def primary_web_host
role(:web).primary_host
def primary_host
primary_role.primary_host
end
def primary_role
role(:web) || roles.first
end
def traefik_hosts
@@ -208,7 +212,7 @@ class Kamal::Configuration
{
roles: role_names,
hosts: all_hosts,
primary_host: primary_web_host,
primary_host: primary_host,
version: version,
repository: repository,
absolute_image: absolute_image,