fix: allow configurations without web roles
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base
|
||||
|
||||
def run
|
||||
web = config.role(:web)
|
||||
return unless web.present?
|
||||
|
||||
docker :run,
|
||||
"--detach",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user