-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Terminal window close from task #782
Comments
Hi @Vlaaaaaaad! Normally, multiple tasks ( tasks:
- before: # ...
- init: # ...
- command: # ... This will run all tasks in parallel in multiple Terminals. I think what you want instead is: tasks:
- before: # ...
init: # ...
command: # ... This will open a single Terminal (only one |
Also, on a random note, you can give more relevant names to each Terminal, like so: tasks:
- name: DB
init: ./install-db.sh
command: ./start-db.sh
- name: Server
init: ./install-server.sh
command: ./start-server.sh |
What you can do is use Bash's tasks:
- command: cat ohno.txt || printf "\nPlease try running 'touch ohno.txt' first.\n\n" |
Yes, I had two tasks in
I wanted the user to see the SSH setup and Terraform init window when the workspace starts and the Install pre-commit hooks terminal window to close if it ran successfully. Buuuut I think I can break SSH setup and Terraform init into two tasks and maaaybe combine them nicely. I will experiment now and report back -- I am planing to open-source this when it's ready either way. Thank you so much! |
I'd still like to have the option to close the Terminal window from a task so I will leave this open. Is that ok? The following works great meanwhile: image:
file: .gitpod/.gitpod.dockerfile
tasks:
- name: Prepare workspace
before: >
pre-commit install --install-hooks
&& printf "\n \n \n Please close this window"
init: > # This runs only on fresh workspace creation
.gitpod/ssh-keys-setup.sh
&& terraform init -backend=false -input=false
&& printf "\n \n \n Please close this window" |
Sure, although I'm not exactly sure what the use case would be, we can definitely leave this issue open until we figure out a way to programmatically close a Terminal. 🙂
Cool that you got it to work! But just to be sure, are you certain that this is the intended behavior? # Workspace creation steps (i.e. `before` && `init`)
pre-commit install --install-hooks
printf "\n \n \n Please close this window"
.gitpod/ssh-keys-setup.sh
terraform init -backend=false -input=false
printf "\n \n \n Please close this window"
# Workspace restart steps (i.e. just `before`)
pre-commit install --install-hooks
printf "\n \n \n Please close this window" I find it strange that Personally, I'd be tempted to simplify the tasks like so: tasks:
- init: >
pre-commit install --install-hooks &&
.gitpod/ssh-keys-setup.sh &&
terraform init -backend=false -input=false This would run all init steps in sequence (or show you exactly where it failed), and you'd only ever have one Terminal, which is simpler UX as having multiple Terminals opening and closing themselves. |
Hm... I wanted to keep the SSH setup and Terraform init step in an My logic is that:
Does this make sense? Did I understand the order and usage of the tasks properly? |
Thanks for the helpful clarifications! 👍
Actually, this will only be executed once, when the workspace is created. If you stop the workspace, and then click on "Start" again, only
Aha, so indeed having this in a separate, less visible Terminal is a good idea. However, if the SSH keys setup process is interactive (you're mentioning prompts), it should be done inside a Now,
That makes a ton of sense. Any long-running, non-interactive step that should be run once on workspace creation is a great candidate for With prebuilds, the
You're 100% correct here as well: any short environment setup step that should be run on every workspace start is a great fit for Furthermore, if you want this to run on every shell session (e.g. re-run it when a user manually opens a new terminal), you may also consider adding that to |
After intense thought I decided not to do it completely different 😆 Workflows will always be different( SSH is needed for modules I work for a company for example, but not for modules in terraform-aws-modules). Having Gitpod start with a ton of terminals waiting for input just because it may be helpful is annoying UX. I tried looking into setting up a custom command or something like that, but I did not find a way( other than an extension which is overkill). So I decided to build a base image with all the helper scripts( which are still WIP) in I have SSH setup( form env var or with krypt.co) and GPG setup( env var or krypt.co) which should be more than enough for now. The pre-commit install is desired all the time so that's the only thing left:
On that happy note I am closing this issue. Thank you for all your help! |
@Vlaaaaaaad So cool that you managed to make it work! 🎉
That's something we'd really like to have, but haven't been able to implement yet. See also #247, which proposes to support standard VS Code task definitions. Meanwhile, building an image with helper scripts is a really cool and smart way to achieve that. 💯
Exciting! Does your env var setup work somewhat like this: #666 (comment) ? Also, I didn't know krypt.co -- what would a SSH/GPG Gitpod setup with krypt.co look like? |
Well, GPG is still to be implemented( I don't do any vanilla GPG cause UX), but the SSH helper does work that way( because I have colleagues who don't use krypt.co and want an env var)!
Kind of like Yubikeys, but with a phone app. I like it because I always have my phone with me 😅 |
That's a super cool SSH helper! Thanks a lot for sharing it. 😄 Also, Krypt.co does sound like a very useful utility. Maybe we could somehow integrate it into Gitpod itself to make SSH/GPG UX more convenient. E.g. if Krypt.co ever ships a VS Code extension that does the QR code setup, we could install it by default in Gitpod. ✨ In any case, the helper scripts you wrote look like they'll work really well -- good luck with your project! Please feel free to reach out if you'd like help with anything else. 🙂 |
Hi,
When having multiple tasks( be they
init
,before
, orcommand
) a lot of terminals end up remaining open with... misleading titles. I'd love to be able to close the terminal on successful execution of the task.I've tried both
exit
which just closes the running command, but not the terminal window. Combinations ofkill -9
andps
led nowhere either.Going further, for failing tasks I'd like the option to pretty print some helpful instructions: Hey, this failed cause X so please try running this command: ****, but that's more intense I think.
The text was updated successfully, but these errors were encountered: