From 2f968ee4939ad839275cec0428f62d1c2553f027 Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Wed, 21 Aug 2024 09:23:55 -0400 Subject: [PATCH] issue #3182: introduce DAP_HOST and DAP_PORT Signed-off-by: Ricky Ng-Adam --- aries_cloudagent/__main__.py | 8 ++++---- docs/features/DevReadMe.md | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/aries_cloudagent/__main__.py b/aries_cloudagent/__main__.py index 2677b8cc8e..6b4ebc76f7 100644 --- a/aries_cloudagent/__main__.py +++ b/aries_cloudagent/__main__.py @@ -20,13 +20,13 @@ def init_debug(args): # --debug to use microsoft's visual studio remote debugger if ENABLE_PTVSD or "--debug" in args: - PTVSD_HOST = os.getenv("PTVSD_HOST", "localhost") - PTVSD_PORT = os.getenv("PTVSD_PORT", 5678) + DAP_HOST = os.getenv("PTVSD_HOST", None) or os.getenv("DAP_HOST", "localhost") + DAP_PORT = os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678) try: import debugpy - debugpy.listen((PTVSD_HOST, PTVSD_PORT)) - print(f"=== Waiting for debugger to attach to {PTVSD_HOST}:{PTVSD_PORT} ===") + debugpy.listen((DAP_HOST, DAP_PORT)) + print(f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ===") debugpy.wait_for_client() except ImportError: print("debugpy library was not found") diff --git a/docs/features/DevReadMe.md b/docs/features/DevReadMe.md index d11553c302..debd55e5b3 100644 --- a/docs/features/DevReadMe.md +++ b/docs/features/DevReadMe.md @@ -182,7 +182,18 @@ For example: ./scripts/run_docker start --inbound-transport http 0.0.0.0 10000 --outbound-transport http --debug --log-level DEBUG ``` -To enable the [ptvsd](https://github.com/Microsoft/ptvsd) Python debugger for Visual Studio/VSCode use the `--debug` command line parameter. +To enable the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) using the [debugpy implementation for Python 3](https://github.com/microsoft/debugpy/) Python debugger for Visual Studio/VSCode use the `--debug` command line parameter. + +When debugging an agent running within a docker container, you will need to set the DAP_HOST environment variable (defaults to ```localhost```) to ```0.0.0.0``` to allow forwarding from within your docker container. + +Note that you may still find references to [PTVSD](https://github.com/microsoft/ptvsd), the deprecated implementation of DAP. PTVSD_HOST and PTVSD_PORT are interchangeable with DAP_HOST and DAP_PORT. + +Example: + +```bash +ENV_VARS="DAP_HOST=0.0.0.0" scripts/run_docker provision --log-level debug --wallet-type askar --wallet-name $(whoami) --wallet-key mysecretkey --endpoint http://localhost:8080 --no-ledger --debug +``` + Any ports you will be using from the docker container should be published using the `PORTS` environment variable. For example: