-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Auto-run task on folder close in addition to open #65986
Comments
On your launch config you can specify a |
Hi @alexr00, nice to hear from you. I tend to set a number of things up before debug such as "stop remote process on server and activate SSH port forwarding to local" and e.g. start local Redis service which would be really nice to reverse on folder close. These are things you don't want to turn on and off each time you start and stop debugging. The clean-up stuff is also not very appropriate to run as a Appreciate this might not be the most urgent thing in the world but I think it's the right approach and is symmetrical with the fantastic task-run-on-folder-open you implemented. 😀 |
@markfinlabs makes sense, I just wanted to make sure there wasn't already something out there that would solve the problem! |
Sure, no trouble. |
I've just began using the |
I would also love this. In my current setup I use {
"label": "Start development services",
"type": "docker-compose",
"presentation": {
"reveal": "silent",
"close": true,
},
"runOptions": {
"runOn": "folderOpen",
},
"dockerCompose": {
"up": {
"detached": true,
"build": true
},
"files": [
"${workspaceFolder}/.ci/dev/docker-compose.yml"
],
},
}, This is nice because the task disappears when the services has started, and then avoiding clutter my terminal view. However with this config there doesn't seem to be any way of stopping the services, once I leave the folder / VSCode. My current solutionI do not run docker compose in detached mode. This takes advantage of the fact that if the task is left running indefinitely, you can emulate #!/bin/bash
on_folder_close() {
echo This is run when the folder / VSCode closes
trap - SIGINT
kill -- -$$
}
trap on_folder_close SIGINT
echo This is run when the folder is opened
sleep infinity While this produce the expected behavior, someone else should probably look it over, since I am not an expert on signal handling or bash. The disadvantage here is that the task will always be visible in the terminal view, but it helps if you set presentation.reveal to "silent". Here is my final task: {
"label": "Start development services",
"type": "docker-compose",
"presentation": {
"reveal": "silent",
},
"runOptions": {
"runOn": "folderOpen",
},
"dockerCompose": {
"up": {
"detached": false,
"build": true
},
"files": [
"${workspaceFolder}/docker-compose.yml"
],
},
}, |
@alexr00 I know this has been closed as out of scope, but is there any way to get this considered again? |
I imagine a feature like this would be quite powerful to use in addition to the Cloud Changes feature. You could save changes on folderClose and retrieve them elsewhere on folderOpen. |
Thanks very much for adding "run on folder open" to tasks. I wish to request a "run on folder close" to complement this to e.g. stop services that are started on folder open.
I describe my use case in this comment: #54775 (comment).
Another use case is process clean-up. For instance, when using Debug Start with nodemon-hosted Node JS processes, if you quit VSCode "node" processes are left orphaned (and consuming CPU) as shown in Activity Monitor. I would like to do process clean-up in a folder-close task rather than manually in Activity Monitor after quitting VS Code.
The text was updated successfully, but these errors were encountered: