-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Kamal to run without traefik #580
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/kamal/cli/healthcheck.rb
Outdated
@@ -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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we raise an exception here instead and protect the callers with if statements? If someone managed to call this without a web role, I think it would be better to fail then to silently pass the check.
lib/kamal/commands/healthcheck.rb
Outdated
@@ -2,6 +2,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base | |||
|
|||
def run | |||
web = config.role(:web) | |||
return unless web.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again could we raise here instead of returning?
f9214c9
to
7472e5d
Compare
Thanks a lot for the feedback 🙏 @djmb I've addressed your comments and resolved the conflicts. Due to #577 there are some important changes in my PR:
cc @mdkent Regarding your comment on the
|
@@ -3,6 +3,7 @@ class Kamal::Cli::Healthcheck < Kamal::Cli::Base | |||
|
|||
desc "perform", "Health check current app version" | |||
def perform | |||
raise "The primary host is not configured to run Traefik" unless KAMAL.config.role(KAMAL.config.primary_role).running_traefik? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KAMAL.config.role(KAMAL.config.primary_role)
might be too verbose.
In my original changes, KAMAL.config.primary_role
was an instance of Role
.
However, with #577, KAMAL.config.primary_web_role
was introduced as a String.
I didn't want to change that to make the review simpler and focusing on what matters. However, if you think a cleanup might be interesting, I can submit another PR afterwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yoelcabo - yes if you could raise another PR to convert KAMAL.config.primary_role
to a Role
that would be great. I'll merge this PR now 🙏
Related discussion: #345
I know Kamal is designed for deploying web applications, as DHH was mentioning here: #191 (comment)
That said, the code change is small, and I think there is a valid use case for not having a web role:
Our use case
We are slowly migrating out of Heroku/AWS. Our first step was migrating some background workers.
If a worker is unreliable, jobs will be picked by "someone else", but if a web container is unreliable, it can cause serious downtime. That's why we are keeping the web in Heroku for now, but the workers are slowly being moved to Hetzner with Kamal.
A workaround for us was running a web container that was never accessed. However, this makes the configuration confusing, creates unnecessary connections to the database and makes the deployment slower.