Py学习  »  Redis

VS代码启动以调试Redis队列工作程序

thanos.a • 2 年前 • 382 次点击  

我试图在VS代码上创建一个启动配置,以便调试Redis队列后台工作程序。

现有的 发射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队列工作程序的命令有:

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

什么才是正确的选择 发射js 配置,以便使用VS代码启动和调试Redis队列工作程序?

到目前为止,我的结论如下:

{
    "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'
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/127899
 
382 次点击  
文章 [ 1 ]  |  最新文章 2 年前
thanos.a
Reply   •   1 楼
thanos.a    2 年前

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

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

注意:我还更新了版本。

任务。json

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

发射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"
        }
    ]
}