啟動我的 devcontainer 時,我需要運行多個命令才能處理我的專案。例如對于我的 Django 專案,我需要運行:
python manage.py runservercelery -A proj workercelery -A proj beattailwindcss -w -i input.css -o output.css
目前,我手動執行此操作,這有點痛苦。
我知道有一個postStartCommand我可以使用,但我將被迫將我的所有命令分組,&&并且我將無法單獨跟蹤每個命令日志。
我想做的是自動化我目前正在手動執行的操作:打開不同的終端視窗并在每個視窗中運行一個命令,以獲得以下結果:

有沒有辦法做到這一點?或者任何解決方法?謝謝。
uj5u.com熱心網友回復:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// See https://code.visualstudio.com/docs/editor/tasks-appendix
"version": "2.0.0",
"tasks": [
{
"label": "Term 1",
"type": "process",
"command": "/bin/bash",
"isBackground": true, // removes the infinite spinner
"problemMatcher": [],
"presentation": {
"group": "main_tasks",
"reveal": "always",
"panel": "new",
"echo": false, // silence "Executing task ..."
}
},
{
"label": "Django server",
"type": "shell",
"command": "./manage.py runserver 127.0.0.1:8000",
"isBackground": true,
"presentation": {
"group": "main_tasks",
"reveal": "always",
"panel": "new",
}
},
{
"label": "Celery worker",
"type": "shell",
"command": "celery --app dj_config worker --uid=nobody --gid=nogroup --loglevel INFO",
"isBackground": true,
"presentation": {
"group": "background_tasks",
"reveal": "never",
"panel": "new",
"showReuseMessage": false,
}
},
{
"label": "Celery beat",
"type": "shell",
"command": "celery --app dj_config beat --uid=nobody --gid=nogroup --loglevel INFO",
"isBackground": true,
"presentation": {
"group": "background_tasks",
"reveal": "never",
"panel": "new",
"showReuseMessage": false,
},
},
{
"label": "Tailwind watcher",
"type": "shell",
"command": "sleep infinity", // FIXME with real command
"isBackground": true,
"presentation": {
"group": "background_tasks",
"reveal": "never",
"panel": "new",
"showReuseMessage": false,
}
},
{
// This is a compound task to run them all
"label": "Mango Terminals (David)",
"dependsOn": [
"Term 1",
"Django server",
"Tailwind watcher",
"Celery worker",
"Celery beat",
],
"dependsOrder": "parallel", // no dependencies between tasks
"problemMatcher": [],
}
]
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/498280.html
上一篇:在我的VSCode的settings.json中找不到問題[無法寫入用戶設定]
下一篇:MissingPluginException(MissingPluginException(在通道plugins.flutter.io/firebase_core上找不到方法Firebase#init
