VSCode ptvsd:调试不起作用,消失,没有调试控制台日志

时间:2019-02-01 03:54:08

标签: docker visual-studio-code ptvs

我只是将Django应用移动到使用docker, 但是当我尝试使用调试器时,现在它消失了,甚至没有输出调试控制台日志

debug disappear

我已经将以下代码添加到manage.py

    # Allow other computers to attach to ptvsd at this IP address and port.
    ptvsd.enable_attach(address=("localhost", 8001), redirect_output=True)
    # Pause the program until a remote debugger is attached
    ptvsd.wait_for_attach()

已经在docker compose文件中打开了8001端口进行调试

a-django-app:
    ....
    command: ./wait-for-it.sh postgis:5432 -s -- python3 manage.py runserver 0.0.0.0:8000 --enable-debugging
    ports:
      - "8000:8000"
      - "8001:8001"

这是我的启动.json配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Attach (Docker)",
            "type": "python",
            "request": "attach",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}/",  
                    "remoteRoot": "/usr/src/ADjangoApp/"
                }
            ],
            "port": 8001,                   // Set to the remote port.
            "host": "localhost"        // Set to your remote host's public IP address.
        },
    ]
}

命令流程:

  1. 我使用docker-compose up运行应用程序
  2. 我打开VSCode,然后按调试器按钮
  3. 调试器消失

0 个答案:

没有答案