【问题标题】:VS code launch to debug a Redis Queue WorkerVS 代码启动以调试 Redis Queue Worker
【发布时间】:2022-01-16 10:44:03
【问题描述】:

我正在尝试在 VS 代码上创建启动配置,以便调试 Redis Queue 后台工作程序。

现有的 launch.js 包含:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "API",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/src/app/run.py",
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}/src/app"
        }
    ]
}

从常规 bash 终端启动 Redis Queue worker 的命令是:

cd /home/user/api/src/app
source env/bin/activate
rq worker --url redis://localhost:2179

什么是正确的 launch.js 配置,以便我可以使用 VS 代码启动和调试 Redis Queue 工作线程?

截至目前,我得到了以下结果:

{
    "name": "Redis Queue Worker",
    "type": "python",
    "request": "launch",
    "program": "rq",
    "console": "integratedTerminal",
    "cwd": "${workspaceFolder}/src/app",
    "args": ["worker", "--url", "redis://localhost:2179"]
}

这给了我以下错误:

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/api/src/app/rq'

【问题讨论】:

    标签: redis web-worker vscode-debugger


    【解决方案1】:

    经过反复试验,我找到了以下解决方案:

    1. tasks.json文件中创建任务
    2. 在引用任务的现有launch.json 配置中添加“预启动任务”

    注意:我也更新了版本。

    tasks.json

    {
        "version": "2.0.0",
        "tasks": [
                {
                "label": "Redis Queue",
                "command": "./dequeue.sh",
                "type": "shell",
                "options": {"cwd": "${workspaceFolder}"}
            }
        ]
    }
    

    launch.json

    {
        "version": "0.2.0",
        "configurations": [
    
            {
                "name": "API",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/src/app/run.py",
                "console": "integratedTerminal",
                "cwd": "${workspaceFolder}/src/app",
                "preLaunchTask": "Redis Queue"
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 2014-05-07
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      • 1970-01-01
      • 2022-12-20
      • 2019-05-08
      • 1970-01-01
      • 2018-08-28
      相关资源
      最近更新 更多