Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart task if is already running

i have this task that is server for my application:

"tasks": [
    {
        "label": "f1",
        "type": "shell",
        "command": "gunicorn",
        "args": [
            "main:api"
        ],
        "isBackground": true,
    },
]

is mapped on key "F1", now, if this task is active, when i press F1, i want to kill it and start again. So i don't have to press CTRL-C each time i write new function.

How i can implement this behaivor? - Thanks

like image 796
Giovanni Cardamone Avatar asked Mar 09 '18 10:03

Giovanni Cardamone


People also ask

How to open already running terminal in vs code?

To open the terminal: Use the Ctrl+` keyboard shortcut with the backtick character. Use the View > Terminal menu command. From the Command Palette (Ctrl+Shift+P), use the View: Toggle Terminal command.

How do I run code?

That shortcut is Ctrl + Alt + N. There are a few more ways to run code. Pressing F1 and then choosing “Run Code” also works. If you want to type it out after pressing F1, you're free to do that as well.


3 Answers

As suggested by @jahuuar, there's a command for this:

Open the command palette (CMD/CTRL + Shift + P or Menu>View>Command Palette) and type "restart", you'll see "Tasks: Restart Running Task". If that's what you are looking for (it will ask for the task to restart, even if there is only one... Oo), you can then map a keyboard shortcut to that command.

like image 118
BoDeX Avatar answered Oct 30 '22 13:10

BoDeX


As per Visual Studio Code Version 1.39.0 , You can right click the Output Area and choose

"Stop Code Run"

. Hope this is what you are looking for. Thanks

like image 35
Chandra Shekhar Avatar answered Oct 30 '22 13:10

Chandra Shekhar


enter image description here

in the output area you can "Stop Code Run"

like image 27
David S Lee Avatar answered Oct 30 '22 13:10

David S Lee