-
Notifications
You must be signed in to change notification settings - Fork 482
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 running detached app commands and follow logs by container ID #906
Conversation
687f08b
to
1cac6e5
Compare
1cac6e5
to
d2edf8d
Compare
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 @aliismayilov,
Sorry for the delay in getting to this! I think we just need some checks for invalid option combinations and we should be good to go!
Also it looks like there are some test failures - |
6a21493
to
a978ed2
Compare
Thanks for looking into this! I've added an incompatibility check. See if it makes sense.
Not anymore! I must've missed them in the avalanche of log lines 😄 |
I just realized that there will be no output from a detached container in the logs. I created a separate issue: #1154 |
a978ed2
to
765e441
Compare
fb1b4bf
to
bc049e7
Compare
@djmb I've updated the pull request with more changes to support logs inspection for detached containers. In short:
I've also updated the pull request description. |
this is useful for long running rake tasks or scripts that can be run without having to keep open connection to the server. Example: ``` kamal app exec 'bin/rails db:backfill_task' --detach ```
091a836
to
ac90ee0
Compare
@djmb I've rebased the PR. There shouldn't be any conflicts or failures 😬 |
e806242
to
8a7843c
Compare
|
||
private | ||
|
||
def container_id_command(container_id) |
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.
TBH, I'm not happy about this approach, but I couldn't come up with a better approach that would allow passing literal container ID (via kamal command) and a command that outputs container ID (see: lib/kamal/cli/app/boot.rb)
OK, I fixed the failing spec and to be sure, the CI passes on my |
This is useful for long running rake tasks or scripts that can be run without having to keep an open connection to servers.
The command that starts a detached container exits immediately and the output leaves the container ID that can be used for following the logs or investigating them later. To support this, I've also extended the
kamal logs
command with--container-id
option.Example:
To support logs inspection, I've also applied kamal logging config to all newly started
app exec
containers. This resolves #1154.