Skip to content

Commit

Permalink
issue openwallet-foundation#3182: introduce DAP_HOST and DAP_PORT
Browse files Browse the repository at this point in the history
Signed-off-by: Ricky Ng-Adam <ricky.ng-adam-ext@mcn.gouv.qc.ca>
  • Loading branch information
rngadam committed Aug 21, 2024
1 parent 7cf389b commit 091e167
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions aries_cloudagent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 12 additions & 1 deletion docs/features/DevReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 091e167

Please sign in to comment.