8000 Add in a server exec command for running ad-hoc commands directly on the server by nickhammond · Pull Request #646 · basecamp/kamal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add in a server exec command for running ad-hoc comman 8000 ds directly on the server #646

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

Merged
merged 3 commits into from
May 21, 2024

Conversation

nickhammond
Copy link
Contributor
@nickhammond nickhammond commented Jan 12, 2024

This PR adds a kamal server exec command to the CLI which was mentioned in this discussion thread: #371

Running an interactive command against the server, same option that you pass for an accessory or app container:

$ kamal server exec --interactive "/bin/bash"
Running '/bin/bash' on 867.53.0.9 interactively...
root@server-1:~#

Running a command across all matching servers/roles/etc., output is displayed for each host:

$ kamal server exec "date"     
Running 'date' on 867.53.0.9...
  INFO [8c0d0725] Running /usr/bin/env date on 867.53.0.9
  INFO [8c0d0725] Finished in 0.192 seconds with exit status 0 (successful).
App Host: 867.53.0.9
Mon May 13 20:45:58 UTC 2024

You can pass all of the usual filters such as role or host to target those specific servers:

$ kamal server exec "date" -r web
Running 'date' on 867.53.0.9...
  INFO [62769fed] Running /usr/bin/env date on 867.53.0.9
  INFO [62769fed] Finished in 0.182 seconds with exit status 0 (successful).
App Host: 867.53.0.9
Mon May 13 20:55:41 UTC 2024

@djmb
Copy link
Collaborator
djmb commented Mar 4, 2024

Looks great @nickhammond 🙏

I think we should go ahead with the interactive version as well though - would you be able to add that?

@nickhammond
Copy link
Contributor Author

@djmb Yah, I'll explore that this week when I get some time.

@abuaboud
Copy link
abuaboud commented Mar 5, 2024

can't wait for this to be released. It's a small thing, but very crucial for us.

Thank you @nickhammond

@Sija
Copy link
Contributor
Sija commented Mar 5, 2024

@djmb Perhaps the interactive version could be merged as a followup in order to proceed with this PR?

@abuaboud
Copy link

Hi @nickhammond and @djmb,

Is there anything remaining in this PR or blocking? we would love to use it as soon as possible.

Thank you so much!

@nickhammond
Copy link
Contributor Author

@djmb Just added in the interactive version with run_locally. I'm not super familiar with SSHKit so if there's a better way to do this let me know. It mirrors the same options and flow that you'd normally use with an accessory or an app container to run exec.

Copy link
Contributor
@igor-alexandrov igor-alexandrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Thank you.

Copy link
Collaborator
@djmb djmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nickhammond - just a couple of minor suggestions, then I think we'll be good to go 👍

Copy link
Contributor Author
@nickhammond nickhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djmb Thanks for the review and good call on the primary_host instead of first.

Co-authored-by: Donal McBreen <dmcbreen@gmail.com>
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
@djmb
Copy link
Collaborator
djmb commented May 21, 2024

Thanks @nickhammond!

@djmb djmb merged commit 9700e2b into basecamp:main May 21, 2024
8 checks passed
@nickhammond nickhammond deleted the server/exec branch May 21, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0